Hey Padraig,

I think you're moving in the right direction so far. Some things to
think about:

Perhaps if you did:

class buffpek_compare
{
  qsort_cmp2 key_compare;
  void *key_compare_arg;

  public:
  buffpek_compare(qsort_cmp2 in_key_compare, void* in_compare_arg)
    : key_compare(in_key_compare), key_compare_arg(in_compare_arg) { }
  inline bool operator()(BUFFPEK *i, BUFFPEK *j)
  {
    return key_compare(key_compare_arg,
                            *((unsigned char **) i->key), *((unsigned
char **) j->key));
  }
};

instead, you could remove the need for the extra Context struct, since
your function object has its own way to store context.

The next step being to get rid of buffpek_compare all together and
replace the qsort_cmp2 that's passed in with a function object itself
which could be directly handed to std::sort() or to priority_queue as
its sort function param.

resuse_freed_buff() looks more like memory management "cleverness" that
would be unneeded if you used priority_queue in the first place. It
sounds like you're guessing the same thing already - but good choice to
take it slow and deal with it piece by piece.

Where was the tree you had the changes in again?

Monty

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to