[asterisk-commits] russell: branch russell/events r81124 - in /team/russell/events: include/aste...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 27 16:22:26 CDT 2007


Author: russell
Date: Mon Aug 27 16:22:26 2007
New Revision: 81124

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81124
Log:
Add ao2_realloc()

Modified:
    team/russell/events/include/asterisk/astobj2.h
    team/russell/events/main/astobj2.c

Modified: team/russell/events/include/asterisk/astobj2.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/include/asterisk/astobj2.h?view=diff&rev=81124&r1=81123&r2=81124
==============================================================================
--- team/russell/events/include/asterisk/astobj2.h (original)
+++ team/russell/events/include/asterisk/astobj2.h Mon Aug 27 16:22:26 2007
@@ -161,6 +161,8 @@
  *   rather, we just call ao2_ref(o, -1);
  */
 void *ao2_alloc(const size_t data_size, ao2_destructor_fn destructor_fn);
+
+void *ao2_realloc(void *data, const size_t data_size);
 
 /*!
  * Reference/unreference an object and return the old refcount.

Modified: team/russell/events/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/astobj2.c?view=diff&rev=81124&r1=81123&r2=81124
==============================================================================
--- team/russell/events/main/astobj2.c (original)
+++ team/russell/events/main/astobj2.c Mon Aug 27 16:22:26 2007
@@ -212,6 +212,22 @@
 	ast_atomic_fetchadd_int(&ao2.total_refs, 1);
 
 	/* return a pointer to the user data */
+	return EXTERNAL_OBJ(obj);
+}
+
+void *ao2_realloc(void *data, size_t data_size)
+{
+	struct astobj2 *obj;
+
+	if (data_size < sizeof(void *))
+		data_size = sizeof(void *);
+
+	if (!(obj = INTERNAL_OBJ(data)))
+		return NULL;
+
+	if (!(data = ast_realloc(data, sizeof(*obj) + data_size)))
+		return NULL;
+
 	return EXTERNAL_OBJ(obj);
 }
 




More information about the asterisk-commits mailing list