diff options
| author | Michael Kerrisk <mtk.manpages@gmail.com> | 2007-04-12 22:42:49 +0000 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2007-04-12 22:42:49 +0000 |
| commit | c13182efa3b3d77f2563034c8212c0ca798243ca (patch) | |
| tree | e7652b26018b7c22cd6a4e4b41404dfaab911303 /man3/malloc_hook.3 | |
| parent | 4174ff5658082832c2ed511720f18881b3a80a34 (diff) | |
| download | man-pages-c13182efa3b3d77f2563034c8212c0ca798243ca.tar.gz | |
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
white space.
Diffstat (limited to 'man3/malloc_hook.3')
| -rw-r--r-- | man3/malloc_hook.3 | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/man3/malloc_hook.3 b/man3/malloc_hook.3 index 4e20eb8d77..f53b5d9863 100644 --- a/man3/malloc_hook.3 +++ b/man3/malloc_hook.3 @@ -5,24 +5,24 @@ .TH MALLOC_HOOK 3 2002-07-20 "GNU" "Linux Programmer's Manual" .SH NAME __malloc_hook, __malloc_initialize_hook, -__memalign_hook, __free_hook, __realloc_hook, +__memalign_hook, __free_hook, __realloc_hook, __after_morecore_hook \- malloc debugging variables .SH SYNOPSIS .sp .BR "#include <malloc.h>" .sp -.BI "void *(*__malloc_hook)(size_t " size , +.BI "void *(*__malloc_hook)(size_t " size , .BI "const void *" caller ); .sp -.BI "void *(*__realloc_hook)(void *" ptr , -.BI "size_t " size , +.BI "void *(*__realloc_hook)(void *" ptr , +.BI "size_t " size , .BI "const void *" caller ); .sp .BI "void *(*__memalign_hook)(size_t " alignment , .BI "size_t " size , .BI "const void *" caller ); .sp -.BI "void (*__free_hook)(void *" ptr , +.BI "void (*__free_hook)(void *" ptr , .BI "const void *" caller ); .sp .BI "void (*__malloc_initialize_hook)(void);" @@ -34,14 +34,16 @@ The GNU C library lets you modify the behavior of .BR realloc (), and .BR free () -by specifying appropriate hook functions. You can use these hooks +by specifying appropriate hook functions. +You can use these hooks to help you debug programs that use dynamic memory allocation, for example. .LP The variable .B __malloc_initialize_hook points at a function that is called once when the malloc implementation -is initialized. This is a weak variable, so it can be overridden in +is initialized. +This is a weak variable, so it can be overridden in the application with a definition like the following: .br .nf @@ -79,26 +81,26 @@ Here is a short example of how to use these variables. .nf #include <stdio.h> #include <malloc.h> - + /* Prototypes for our hooks. */ static void my_init_hook(void); static void *my_malloc_hook(size_t, const void *); /* Variables to save original hooks. */ static void *(*old_malloc_hook)(size_t, const void *); - + /* Override initialising hook from the C library. */ void (*__malloc_initialize_hook) (void) = my_init_hook; static void -my_init_hook(void) +my_init_hook(void) { old_malloc_hook = __malloc_hook; __malloc_hook = my_malloc_hook; } static void * -my_malloc_hook(size_t size, const void *caller) +my_malloc_hook(size_t size, const void *caller) { void *result; |
