[svn-commits] kpfleming: branch kpfleming/aligner r126733 - /team/kpfleming/aligner/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 30 19:22:37 CDT 2008


Author: kpfleming
Date: Mon Jun 30 19:22:37 2008
New Revision: 126733

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126733
Log:
fix two serious problems with this code... outbuf needs to be set to the address of the buffer *after* the AST_FRIENDLY_OFFSET padding, and pass the proper arguments to the <foo>_force macros for allocating and aligning elements

tomorrow I'll work on a whole new implementation of this stuff, that will reduce these chances for error and code duplication


Modified:
    team/kpfleming/aligner/main/translate.c

Modified: team/kpfleming/aligner/main/translate.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/aligner/main/translate.c?view=diff&rev=126733&r1=126732&r2=126733
==============================================================================
--- team/kpfleming/aligner/main/translate.c (original)
+++ team/kpfleming/aligner/main/translate.c Mon Jun 30 19:22:37 2008
@@ -108,16 +108,17 @@
 	*/
 	len = sizeof(*pvt);
 
-	ast_align_update_space_force(&len, 1, t->desc_size, void *);
+	ast_align_update_space_force(&len, t->desc_size, char, void *);
 
 	if (useplc) {
 		ast_align_update_space(&len, 1, plc_state_t);
 	}
 
-	/* the output buffer can hold 16-bit elements, so perform the alignment for that case */
-
 	if (t->buf_size) {
-		ast_align_update_space_force(&len, 1, AST_FRIENDLY_OFFSET + t->buf_size, short);
+		/* put in some padding like we do for all frames, using AST_FRIENDLY_OFFSET */
+		ast_align_update_space(&len, AST_FRIENDLY_OFFSET, char);
+		/* the output buffer can hold 16-bit elements, so perform the alignment for that case */
+		ast_align_update_space_force(&len, t->buf_size, char, short);
 	}
 
 	if (!(pvt = ast_calloc(1, len))) {
@@ -128,14 +129,18 @@
 
 	offset = sizeof(*pvt);
 
-	pvt->pvt = ast_align_compute_element_ptr_force(pvt, &offset, 1, t->desc_size, void *);
-
-	if (useplc) {			/* then plc state */
+	pvt->pvt = ast_align_compute_element_ptr_force(pvt, &offset, t->desc_size, char, void *);
+
+	if (useplc) {
+		/* plc state */
 		pvt->plc = ast_align_compute_element_ptr(pvt, &offset, 1, plc_state_t);
 	}
 
-	if (t->buf_size) {		/* finally buffer and header */
-		pvt->outbuf = ast_align_compute_element_ptr_force(pvt, &offset, 1, AST_FRIENDLY_OFFSET + t->buf_size, short);
+	if (t->buf_size) {
+		/* skip the padding */
+		ast_align_compute_element_ptr(pvt, &offset, AST_FRIENDLY_OFFSET, char);
+		/* get the buffer address */
+		pvt->outbuf = ast_align_compute_element_ptr_force(pvt, &offset, t->buf_size, char, short);
 	}
 
 	/* call local init routine, if present */




More information about the svn-commits mailing list