CVS update: samba/source/lib

Tim Potter tpot at linuxcare.com.au
Wed Jul 19 23:46:35 GMT 2000


Luke Kenneth Casson Leighton writes:

> > On a slightly different note, I've noticed a problem with very
> > large arrays.  The memory allocator in glibc 2.1 seems to crash
> > with arrays of about 40,000 elements, probably because of
> > fragmentation caused by calls to realloc().  If it's possible to
> > determine the size of the array beforehand, I tend to malloc()
> > the array beforehand and copy elements in using array
> > assignment. 

> this seems to imply that a uint32, void** is not good enough.  that what
> is needed is something simpilar to that used in apache: ap_table
> structure, maybe.
> 
> or, using talloc and trealloc or sander's mem-alloc code.

Well if you want to be really picky it shouldn't be necessary to
change the code at all!  Anton has seen the same behaviour on a
particular sparc setup.

> struct
> {
> 	uint32 size;
> 	uint32 alloced_size; /* multiple of 16? 32? */
> 	void** array;
> }
> 
> is another alternative.

Yup.  Just realloc() more than one entry when you have to and keep
track of how may you have used.


Tim.





More information about the samba-technical mailing list