Re: [AD] mode-list updates. |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
>> If realloc fails (it returns NULL), you'll have a memory leak.
>> Sorry about being cryptic yesterday.
>
>I read further through the docs, the GNU libc docs are a bit cryptic, but my
>old "using turbo c" book says realloc frees memory and returns NULL if
>re-allocation fails. The question is if we can rely on this.
>
FYI from the gcc info file:
- Function: void * realloc (void *PTR, size_t NEWSIZE)
The `realloc' function changes the size of the block whose address
is PTR to be NEWSIZE.
<snip>
If you pass a null pointer for PTR, `realloc' behaves just like
`malloc (NEWSIZE)'. This can be convenient, but beware that older
^^^^^^^^^^^^^^^^^
implementations (before ISO C) may not support this behavior, and
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
will probably crash when `realloc' is passed a null pointer.
Like `malloc', `realloc' may return a null pointer if no memory
space is available to make the block bigger. When this happens, the
^^^
original block is untouched; it has not been modified or relocated.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<snip>
--
Martijn Versteegh