[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PATCH: Fix docs for caller arg for memory allocation hooks
From: |
Martin Buchholz |
Subject: |
PATCH: Fix docs for caller arg for memory allocation hooks |
Date: |
Wed, 1 Nov 2000 18:24:01 +0900 (JST) |
Beyond the changes indicated here, you might want to mention that the
type of the `caller' arg changed from void * to const void *. A
portable C++-compilable program (like xemacs) would have to
autoconfiscate the changes.
Index: ChangeLog
===================================================================
RCS file: /cvs/libc/ChangeLog,v
retrieving revision 1.4281
diff -u -w -U0 -r1.4281 ChangeLog
--- ChangeLog 2000/09/08 08:41:44 1.4281
+++ ChangeLog 2000/11/01 09:21:23
@@ -0,0 +1,5 @@
+2000-11-01 Martin Buchholz <address@hidden>
+
+ * manual/memory.texi (Hooks for Malloc):
+ Fix `caller' arg docs to agree with implementation.
+
Index: manual/memory.texi
===================================================================
RCS file: /cvs/libc/manual/memory.texi,v
retrieving revision 1.69
diff -u -w -r1.69 memory.texi
--- manual/memory.texi 2000/06/01 19:01:54 1.69
+++ manual/memory.texi 2000/11/01 09:21:26
@@ -841,7 +841,7 @@
function to look like @code{malloc}; that is, like:
@smallexample
-void address@hidden (size_t @var{size}, void address@hidden)
+void address@hidden (size_t @var{size}, const void address@hidden)
@end smallexample
The value of @var{caller} is the return address found on the stack when
@@ -857,7 +857,7 @@
like @code{realloc}; that is, like:
@smallexample
-void address@hidden (void address@hidden, size_t @var{size}, void
address@hidden)
+void address@hidden (void address@hidden, size_t @var{size}, const void
address@hidden)
@end smallexample
The value of @var{caller} is the return address found on the stack when
@@ -873,7 +873,7 @@
like @code{free}; that is, like:
@smallexample
-void @var{function} (void address@hidden, void address@hidden)
+void @var{function} (void address@hidden, const void address@hidden)
@end smallexample
The value of @var{caller} is the return address found on the stack when
@@ -889,8 +889,12 @@
like @code{memalign}; that is, like:
@smallexample
-void address@hidden (size_t @var{size}, size_t @var{alignment})
+void address@hidden (size_t @var{size}, size_t @var{alignment}, const void
address@hidden)
@end smallexample
+
+The value of @var{caller} is the return address found on the stack when
+the @code{memalign} function was called. This value allows you to trace the
+memory consumption of the program.
@end defvar
You must make sure that the function you install as a hook for one of
@@ -936,14 +940,13 @@
program.
@smallexample
-/* Global variables used to hold underlaying hook values. */
-static void *(*old_malloc_hook) (size_t);
-static void (*old_free_hook) (void*);
+/* Prototypes for __malloc_hook, __free_hook */
+#include <malloc.h>
/* Prototypes for our hooks. */
static void *my_init_hook (void);
-static void *my_malloc_hook (size_t);
-static void my_free_hook (void*);
+static void *my_malloc_hook (size_t, const void *);
+static void my_free_hook (void*, const void *);
/* Override initializing hook from the C library. */
void (*__malloc_initialize_hook) (void) = my_init_hook;
@@ -958,7 +961,7 @@
@}
static void *
-my_malloc_hook (size_t size)
+my_malloc_hook (size_t size, const void *caller)
@{
void *result;
/* Restore all old hooks */
@@ -978,7 +981,7 @@
@}
static void *
-my_free_hook (void *ptr)
+my_free_hook (void *ptr, const void *caller)
@{
/* Restore all old hooks */
__malloc_hook = old_malloc_hook;
@@ -1109,16 +1112,16 @@
dynamically allocated memory, and to call @var{abortfn} when an
inconsistency is found. @xref{Heap Consistency Checking}.
address@hidden void *(*__malloc_hook) (size_t @var{size}, void address@hidden)
address@hidden void *(*__malloc_hook) (size_t @var{size}, const void
address@hidden)
A pointer to a function that @code{malloc} uses whenever it is called.
address@hidden void *(*__realloc_hook) (void address@hidden, size_t @var{size},
void address@hidden)
address@hidden void *(*__realloc_hook) (void address@hidden, size_t @var{size},
const void address@hidden)
A pointer to a function that @code{realloc} uses whenever it is called.
address@hidden void (*__free_hook) (void address@hidden, void address@hidden)
address@hidden void (*__free_hook) (void address@hidden, const void
address@hidden)
A pointer to a function that @code{free} uses whenever it is called.
address@hidden void (*__memalign_hook) (size_t @var{size}, size_t
@var{alignment})
address@hidden void (*__memalign_hook) (size_t @var{size}, size_t
@var{alignment}, const void address@hidden)
A pointer to a function that @code{memalign} uses whenever it is called.
@item struct mallinfo mallinfo (void)
- PATCH: Fix docs for caller arg for memory allocation hooks,
Martin Buchholz <=