Hi Matt and everyone,

A few of the reasons for sci_memory:

- Yes there was a bit of duplication. There were at least two or three copies of
what is now sci_malloc lying around.

- A central place to store extra memory allocation functions such as memdup and
strndup which aren't in the standard C library.

- A central place to turn on or off memory allocation checking. This not only
means checking that the return value from malloc is not NULL, but also turning
on usage of the dmalloc library. A very low percentage of malloc and associated
calls were being checked if they == NULL.

- Accurate filename and line number reporting where calls are made or where they
fail without the use of the dmalloc library. Under GNU C, this also includes the
function name.


The current status of the library within the snapshot is:

- Christoph still has a minor CVS commit to make for the configure script (and
other little bits). This will mean that, by default (although Christoph seemed
keen to change this :-) ), all calls to malloc (and its relatives) will be
checked if they == NULL before returning the allocated memory. This can be
turned off in the configure script so that the sci_memory library is effectively
bypassed to use plain ol' malloc, calloc, etc...

- I have changed all calls throughout my local copy of the snapshot that have
replacements within sci_memory to those replacements. It was a pain, but it now
compiles under Win32 and Linux. Once I've done a bit more testing/have CVS
access, I'll submit that to CVS.


Once Christoph has committed the minor update mentioned above to the library, I
strongly recommend that all coders use it, even if they want to turn off the
return malloc == NULL checks.

It's pretty easy, just change your coding as follows:

malloc  -> sci_malloc
calloc  -> sci_calloc
realloc -> sci_realloc
free    -> sci_free
memdup  -> sci_memdup
strdup  -> sci_strdup
strndup -> sci_strndup

Cheers,

Alex.


> On 17 Aug 2001 [EMAIL PROTECTED] wrote:
> 
> > Log message:
> > * Applied Alex' sci_memory patches
> > * Added configure option to select his memory allocation modes
> > * Added Alex to the "About FreeSCI" boxes
> 
> Wow, this is huge. Thanks Alex!
> 
> Was this simply refactoring common bits into a separate file, or is there
> another goal in mind?
> 
> --
> http://www.clock.org/~matt
> 
> 



Reply via email to