On Wed, Nov 07, 2001 at 12:39:32AM -0600, Rob Browning wrote: > [EMAIL PROTECTED] writes: > > So, if we replace malloc, we then need a table of pointers and their > > size. Worth it? > > If we're going to be using it for anything substantial, I tend to > think this would be *extremely* unwise. Writing a good allocator is > *hard*. > > If the performance is critical, then I suspect we should use the > system realloc if/when we can determine (via configure.in) that it's > reliable, and otherwise, we should be using more explicit means. > Using gnu libc's realloc certainly would have worked better in my > case. > > Anyway from a quick glance, it looks like we're only using realloc for > strings, which you can easily determine the length of, and for > lt_caller_data which could be easily augmented to include a size > field. > > So as one approach, we could just have str_realloc() and > realloc_caller_data(), and then these could use the system realloc > internally on platforms where that's considered beneficial.
According to ltdl.h, /* By default, the realloc function pointer is set to our internal realloc implementation which iself uses lt_dlmalloc and lt_dlfree. libltdl relies on a featureful realloc, but if you are sure yours has the right semantics then you can assign it directly. Generally, it is safe to assign just a malloc() and a free() function. */ And, in ltdl.c: /* These are the pointers that can be changed by the caller: */ LT_GLOBAL_DATA lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size)) = (lt_ptr (*) LT_PARAMS((size_t))) malloc; LT_GLOBAL_DATA lt_ptr (*lt_dlrealloc) LT_PARAMS((lt_ptr ptr, size_t size)) = (lt_ptr (*) LT_PARAMS((lt_ptr, size_t))) rpl_realloc; LT_GLOBAL_DATA void (*lt_dlfree) LT_PARAMS((lt_ptr ptr)) = (void (*) LT_PARAMS((lt_ptr))) free; Because ltdl.h already states that libltdl relies on a featureful realloc, let's just set lt_dlrealloc = realloc and test for a featureful realloc in ltdl.m4. Let's recommend that if anyone changes at least one of lt_dlmalloc, lt_dlrealloc, or lt_dlfree, then they should also change them all. Let the client worry about malloc/free and ltdl be somewhat stupid to the choices of the client. -- albert chin ([EMAIL PROTECTED]) _______________________________________________ Libtool mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/libtool