Kaydet (Commit) 558ba52f authored tarafından Neil Schemenauer's avatar Neil Schemenauer

Remove malloc hooks.

üst fa79c652
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
*/ */
/* #undef WITH_MEMORY_LIMITS */ /* disable mem limit checks */ /* #undef WITH_MEMORY_LIMITS */ /* disable mem limit checks */
#define WITH_MALLOC_HOOKS /* for profiling & debugging */
/*==========================================================================*/ /*==========================================================================*/
...@@ -326,16 +325,6 @@ static block *arenalist = NULL; /* list of allocated arenas */ ...@@ -326,16 +325,6 @@ static block *arenalist = NULL; /* list of allocated arenas */
static block *arenabase = NULL; /* free space start address in static block *arenabase = NULL; /* free space start address in
current arena */ current arena */
/*
* Hooks
*/
#ifdef WITH_MALLOC_HOOKS
static void *(*malloc_hook)(size_t) = NULL;
static void *(*calloc_hook)(size_t, size_t) = NULL;
static void *(*realloc_hook)(void *, size_t) = NULL;
static void (*free_hook)(void *) = NULL;
#endif /* !WITH_MALLOC_HOOKS */
/*==========================================================================*/ /*==========================================================================*/
/* malloc */ /* malloc */
...@@ -356,11 +345,6 @@ _PyMalloc_Malloc(size_t nbytes) ...@@ -356,11 +345,6 @@ _PyMalloc_Malloc(size_t nbytes)
poolp next; poolp next;
uint size; uint size;
#ifdef WITH_MALLOC_HOOKS
if (malloc_hook != NULL)
return (*malloc_hook)(nbytes);
#endif
/* /*
* This implicitly redirects malloc(0) * This implicitly redirects malloc(0)
*/ */
...@@ -523,13 +507,6 @@ _PyMalloc_Free(void *p) ...@@ -523,13 +507,6 @@ _PyMalloc_Free(void *p)
uint size; uint size;
off_t offset; off_t offset;
#ifdef WITH_MALLOC_HOOKS
if (free_hook != NULL) {
(*free_hook)(p);
return;
}
#endif
if (p == NULL) /* free(NULL) has no effect */ if (p == NULL) /* free(NULL) has no effect */
return; return;
...@@ -601,11 +578,6 @@ _PyMalloc_Realloc(void *p, size_t nbytes) ...@@ -601,11 +578,6 @@ _PyMalloc_Realloc(void *p, size_t nbytes)
poolp pool; poolp pool;
uint size; uint size;
#ifdef WITH_MALLOC_HOOKS
if (realloc_hook != NULL)
return (*realloc_hook)(p, nbytes);
#endif
if (p == NULL) if (p == NULL)
return _PyMalloc_Malloc(nbytes); return _PyMalloc_Malloc(nbytes);
...@@ -656,11 +628,6 @@ _PyMalloc_Calloc(size_t nbel, size_t elsz) ...@@ -656,11 +628,6 @@ _PyMalloc_Calloc(size_t nbel, size_t elsz)
void *p; void *p;
size_t nbytes; size_t nbytes;
#ifdef WITH_MALLOC_HOOKS
if (calloc_hook != NULL)
return (*calloc_hook)(nbel, elsz);
#endif
nbytes = nbel * elsz; nbytes = nbel * elsz;
p = _PyMalloc_Malloc(nbytes); p = _PyMalloc_Malloc(nbytes);
if (p != NULL) if (p != NULL)
...@@ -669,39 +636,3 @@ _PyMalloc_Calloc(size_t nbel, size_t elsz) ...@@ -669,39 +636,3 @@ _PyMalloc_Calloc(size_t nbel, size_t elsz)
} }
*/ */
/*==========================================================================*/
/*
* Hooks
*/
#ifdef WITH_MALLOC_HOOKS
void
_PyMalloc_SetHooks( void *(*malloc_func)(size_t),
void *(*calloc_func)(size_t, size_t),
void *(*realloc_func)(void *, size_t),
void (*free_func)(void *) )
{
LOCK();
malloc_hook = malloc_func;
calloc_hook = calloc_func;
realloc_hook = realloc_func;
free_hook = free_func;
UNLOCK();
}
void
_PyMalloc_FetchHooks( void *(**malloc_funcp)(size_t),
void *(**calloc_funcp)(size_t, size_t),
void *(**realloc_funcp)(void *, size_t),
void (**free_funcp)(void *) )
{
LOCK();
*malloc_funcp = malloc_hook;
*calloc_funcp = calloc_hook;
*realloc_funcp = realloc_hook;
*free_funcp = free_hook;
UNLOCK();
}
#endif /* !WITH_MALLOC_HOOKS */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment