Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nslcd-common.h
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2006-12-31 11:03:54 +0100
committerArthur de Jong <arthur@arthurdejong.org>2006-12-31 11:03:54 +0100
commitb013f9976e2d620094d3d4584ee8243df2b9c87f (patch)
tree6c5ba3b812ebafbc88a3ef069b865584ceb4994b /nslcd-common.h
parent7783f518f63f885808639374091ea5a67038c935 (diff)
ensure that all arrays that are allocated in the buffer are now aligned to the pointer size
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@209 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd-common.h')
-rw-r--r--nslcd-common.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/nslcd-common.h b/nslcd-common.h
index 6150075..a283fb4 100644
--- a/nslcd-common.h
+++ b/nslcd-common.h
@@ -168,8 +168,19 @@ static void debug_dump(const void *ptr,size_t size)
BUF_CHECK(fp,tmp2int32); \
BUF_SKIP(tmp2int32);
+/* move BUF_CUR foreward so that it is aligned to the specified
+ type width */
+#define BUF_ALIGN(fp,type) \
+ /* figure out number of bytes to skip foreward */ \
+ tmp2int32=(sizeof(type)-((BUF_CUR-(char *)NULL)%sizeof(type)))%sizeof(type); \
+ /* check and skip */ \
+ BUF_CHECK(fp,tmp2int32); \
+ BUF_SKIP(tmp2int32);
+
/* allocate a piece of the buffer to store an array in */
#define BUF_ALLOC(fp,ptr,type,num) \
+ /* align to the specified type width */ \
+ BUF_ALIGN(fp,type); \
/* check that we have enough room */ \
BUF_CHECK(fp,(num)*sizeof(type)); \
/* store the pointer */ \