| www.delorie.com/gnu/docs/gdb/gdbint_110.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GDB does not use the functions malloc, realloc,
calloc, free and asprintf.
GDB uses the functions xmalloc, xrealloc and
xcalloc when allocating memory. Unlike malloc et.al.
these functions do not return when the memory pool is empty. Instead,
they unwind the stack using cleanups. These functions return
NULL when requested to allocate a chunk of memory of size zero.
Pragmatics: By using these functions, the need to check every memory allocation is removed. These functions provide portable behavior.
GDB does not use the function free.
GDB uses the function xfree to return memory to the
memory pool. Consistent with ISO-C, this function ignores a request to
free a NULL pointer.
Pragmatics: On some systems free fails when passed a
NULL pointer.
GDB can use the non-portable function alloca for the
allocation of small temporary values (such as strings).
Pragmatics: This function is very non-portable. Some systems restrict the memory being allocated to no more than a few kilobytes.
GDB uses the string function xstrdup and the print
function xasprintf.
Pragmatics: asprintf and strdup can fail. Print
functions such as sprintf are very prone to buffer overflow
errors.
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |