This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] tdestroy() should allow passing 'NULL' for 'freefct' callback

This is a modest enhancement which would make lives of many developers
a bit more cheerful.

Glibc contains function tdestroy() which is not specified by any standard.
This function is very handy because it allows destroying whole binary
search tree at once.

However the 'freefct' callback cannot be NULL even if no work
is necessary (keys are integers, for example).
I can only speculate why it is so. The only valid reason might be performance:
  (*freefct) ((void *) root->key);
could be called directly in tdestroy_recurse() without checking for
non-NULL first.

However that puts unnecessary burden on the application developers,
although the manpage says that 'freefct' in that case must point to
an empty function. Even glibc itself has such empty function (freenoop).

Glibc should be more friendly in this case and allow passing NULL
for 'freefct".

Please kindly review the attached patch and let me know.
Ivo Raisr

Attachment: glibc-tdestroy-freefct-NULL.patch
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]