[Freeswitch-svn] [commit] r8603 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/su libsofia-sip-ua/su/sofia-sip

Freeswitch SVN mikej at freeswitch.org
Sat May 24 23:25:07 EDT 2008


Author: mikej
Date: Sat May 24 23:25:07 2008
New Revision: 8603

Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c

Log:
Wed May 21 10:42:52 EDT 2008  Pekka Pessi <first.last at nokia.com>
  * su_home_check_alloc(): added



Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Sat May 24 23:25:07 2008
@@ -1 +1 @@
-Sat May 24 23:22:13 EDT 2008
+Sat May 24 23:25:00 EDT 2008

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h	Sat May 24 23:25:07 2008
@@ -103,6 +103,8 @@
 
 SU_DLL void su_home_check(su_home_t const *home);
 
+SU_DLL int su_home_check_alloc(su_home_t const *home, void const *data);
+
 SU_DLL int su_home_mutex_lock(su_home_t *home);
 
 SU_DLL int su_home_mutex_unlock(su_home_t *home);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c	Sat May 24 23:25:07 2008
@@ -283,7 +283,7 @@
   su_block_find_collision_size;
 #endif
 
-su_inline su_alloc_t *su_block_find(su_block_t *b, void const *p)
+su_inline su_alloc_t *su_block_find(su_block_t const *b, void const *p)
 {
   size_t h, h0, probe;
 
@@ -306,8 +306,10 @@
   probe = (b->sub_n > SUB_P) ? SUB_P : 1;
 
   do {
-    if (b->sub_nodes[h].sua_data == p)
-      return &b->sub_nodes[h];
+    if (b->sub_nodes[h].sua_data == p) {
+      su_alloc_t const *retval = &b->sub_nodes[h];
+      return (su_alloc_t *)retval; /* discard const */
+    }
     h += probe;
     if (h >= b->sub_n)
       h -= b->sub_n;
@@ -463,7 +465,7 @@
     home->suh_blocks = b2;
 
     if (sub && !sub->sub_auto)
-      safefree(sub);
+      free(sub);
     sub = b2;
   }
 
@@ -836,6 +838,27 @@
   safefree(data);
 }
 
+/** Check if pointer has been allocated through home.
+ *
+ * @param home   pointer to a memory home
+ * @param data   pointer to a memory area possibly allocated though home
+ */
+int su_home_check_alloc(su_home_t const *home, void const *data)
+{
+  int retval = 0;
+
+  if (home && data) {
+    su_block_t const *sub = MEMLOCK(home);
+    su_alloc_t *allocation = su_block_find(sub, data);
+
+    retval = allocation != NULL;
+
+    UNLOCK(home);
+  }
+
+  return retval;
+}
+
 /** Check home consistency.
  *
  * Ensures that the home structure and all memory blocks allocated through



More information about the Freeswitch-svn mailing list