From: Vincent Bernat Date: Thu, 11 Dec 2008 19:40:36 +0000 (+0100) Subject: Padding and alignment is really the same thing. X-Git-Tag: 0.3~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89590c8f0461b19b6518de10a45ce11277606fe7;p=thirdparty%2Flldpd.git Padding and alignment is really the same thing. --- diff --git a/src/ctl.c b/src/ctl.c index f12b83cf..4988b69c 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -435,6 +435,7 @@ ctl_msg_packunpack_structure(char *format, void *structure, unsigned int size, * occur. */ ce = NULL; if (*f == '(') { + /* We need to align, compute the needed alignment */ if ((align = calloc(1, sizeof(struct stack_align))) == NULL) { LLOG_WARN("unable to allocate memory " @@ -444,17 +445,12 @@ ctl_msg_packunpack_structure(char *format, void *structure, unsigned int size, talign = align->align = ctl_msg_get_alignment(f); SLIST_INSERT_HEAD(&aligns, align, next); } else if (*f == ')') { - /* Pad the structure */ + /* We need to pad, retrieve the needed alignment */ align = SLIST_FIRST(&aligns); talign = align->align; - if ((talign > 0) && (csize % talign != 0)) { - structure += talign - (csize % talign); - csize += talign - (csize % talign); - } align_next = SLIST_NEXT(align, next); SLIST_REMOVE_HEAD(&aligns, next); free(align); - continue; } else { for (ce = conv_table; (ce->format != 0) && (ce->format != *f);