This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

malloc patch for 2.2.4


Hi,

Argh, if the following is the cause for the strange SMP crashes
(haven't yet checked), well, I'll just hide somewhere..

Regards,
Wolfram.

2001-08-21  Wolfram Gloger  <wg@malloc.de>

	* malloc/malloc.c: Make access to ..._hook pointers thread-safe.

--- malloc/malloc.c.orig	Sun Aug 12 03:28:49 2001
+++ malloc/malloc.c	Tue Aug 21 17:37:24 2001
@@ -2788,13 +2788,15 @@
   mchunkptr victim;
 
 #if defined _LIBC || defined MALLOC_HOOKS
-  if (__malloc_hook != NULL) {
+  __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, __const __malloc_ptr_t)) =
+      __malloc_hook;
+  if (hook != NULL) {
     Void_t* result;
 
 #if defined __GNUC__ && __GNUC__ >= 2
-    result = (*__malloc_hook)(bytes, RETURN_ADDRESS (0));
+    result = (*hook)(bytes, RETURN_ADDRESS (0));
 #else
-    result = (*__malloc_hook)(bytes, NULL);
+    result = (*hook)(bytes, NULL);
 #endif
     return result;
   }
@@ -3111,11 +3113,14 @@
   mchunkptr p;                          /* chunk corresponding to mem */
 
 #if defined _LIBC || defined MALLOC_HOOKS
-  if (__free_hook != NULL) {
+  void (*hook) __MALLOC_PMT ((__malloc_ptr_t, __const __malloc_ptr_t)) =
+    __free_hook;
+
+  if (hook != NULL) {
 #if defined __GNUC__ && __GNUC__ >= 2
-    (*__free_hook)(mem, RETURN_ADDRESS (0));
+    (*hook)(mem, RETURN_ADDRESS (0));
 #else
-    (*__free_hook)(mem, NULL);
+    (*hook)(mem, NULL);
 #endif
     return;
   }
@@ -3314,13 +3319,16 @@
   mchunkptr newp;             /* chunk to return */
 
 #if defined _LIBC || defined MALLOC_HOOKS
-  if (__realloc_hook != NULL) {
+  __malloc_ptr_t (*hook) __MALLOC_PMT ((__malloc_ptr_t, size_t,
+                                        __const __malloc_ptr_t)) =
+    __realloc_hook;
+  if (hook != NULL) {
     Void_t* result;
 
 #if defined __GNUC__ && __GNUC__ >= 2
-    result = (*__realloc_hook)(oldmem, bytes, RETURN_ADDRESS (0));
+    result = (*hook)(oldmem, bytes, RETURN_ADDRESS (0));
 #else
-    result = (*__realloc_hook)(oldmem, bytes, NULL);
+    result = (*hook)(oldmem, bytes, NULL);
 #endif
     return result;
   }
@@ -3596,13 +3604,16 @@
   mchunkptr p;
 
 #if defined _LIBC || defined MALLOC_HOOKS
-  if (__memalign_hook != NULL) {
+  __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
+                                        __const __malloc_ptr_t)) =
+    __memalign_hook;
+  if (hook != NULL) {
     Void_t* result;
 
 #if defined __GNUC__ && __GNUC__ >= 2
-    result = (*__memalign_hook)(alignment, bytes, RETURN_ADDRESS (0));
+    result = (*hook)(alignment, bytes, RETURN_ADDRESS (0));
 #else
-    result = (*__memalign_hook)(alignment, bytes, NULL);
+    result = (*hook)(alignment, bytes, NULL);
 #endif
     return result;
   }
@@ -3788,12 +3799,14 @@
   Void_t* mem;
 
 #if defined _LIBC || defined MALLOC_HOOKS
-  if (__malloc_hook != NULL) {
+  __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, __const __malloc_ptr_t)) =
+    __malloc_hook;
+  if (hook != NULL) {
     sz = n * elem_size;
 #if defined __GNUC__ && __GNUC__ >= 2
-    mem = (*__malloc_hook)(sz, RETURN_ADDRESS (0));
+    mem = (*hook)(sz, RETURN_ADDRESS (0));
 #else
-    mem = (*__malloc_hook)(sz, NULL);
+    mem = (*hook)(sz, NULL);
 #endif
     if(mem == 0)
       return 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]