[asterisk-commits] kpfleming: branch kpfleming/aligner2 r153847 - /team/kpfleming/aligner2/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 3 07:32:56 CST 2008


Author: kpfleming
Date: Mon Nov  3 07:32:54 2008
New Revision: 153847

URL: http://svn.digium.com/view/asterisk?view=rev&rev=153847
Log:
another alignment issue fix related to issue #12932


Modified:
    team/kpfleming/aligner2/main/astobj2.c

Modified: team/kpfleming/aligner2/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/aligner2/main/astobj2.c?view=diff&rev=153847&r1=153846&r2=153847
==============================================================================
--- team/kpfleming/aligner2/main/astobj2.c (original)
+++ team/kpfleming/aligner2/main/astobj2.c Mon Nov  3 07:32:54 2008
@@ -109,7 +109,13 @@
 		return NULL;
 	}
 
-	p = (struct astobj2 *) ((char *) user_data - sizeof(*p));
+	/* we know that the user_data pointer is suitably aligned
+	   to be a 'struct astobj2 *', since it was allocated to
+	   begin immediately after the internal object. because of
+	   this, we can directly cast it into one and find the
+	   address of the internal object.
+	*/
+	p = (struct astobj2 *) user_data - 1;
 	if (AO2_MAGIC != (p->priv_data.magic) ) {
 		ast_log(LOG_ERROR, "bad magic number 0x%x for %p\n", p->priv_data.magic, p);
 		p = NULL;




More information about the asterisk-commits mailing list