summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-04-11 14:24:48 +0000
committerAndrew Tridgell <tridge@samba.org>2000-04-11 14:24:48 +0000
commit17ea0bd3b5bcdd18dc812fc6316668785f902f3b (patch)
treeadeb6ca9dec3dfab56b4158f6704ceb0e9fdd4f4 /source3/lib
parent55fa1630e4e2c298e19387ee18b425b86fd02656 (diff)
downloadsamba-17ea0bd3b5bcdd18dc812fc6316668785f902f3b.tar.gz
samba-17ea0bd3b5bcdd18dc812fc6316668785f902f3b.tar.bz2
samba-17ea0bd3b5bcdd18dc812fc6316668785f902f3b.zip
add an align4() function
(This used to be commit 7969f4dccbc5a506ef58b9270a08f8f70d9006f7)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index ebb89c9d89..fdd2b98c56 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2607,13 +2607,26 @@ align a pointer to a multiple of 2 bytes
********************************************************************/
char *align2(char *q, char *base)
{
- if ((q - base) & 1)
+ if (PTR_DIFF(q, base) & 1)
{
q++;
}
return q;
}
+/*******************************************************************
+ align a pointer to a multiple of 4 bytes.
+ ********************************************************************/
+char *align4(char *q, char *base)
+{
+ int mod = PTR_DIFF(q, base) & 3;
+ if (mod != 0)
+ {
+ q += 4-mod;
+ }
+ return q;
+}
+
void out_ascii(FILE *f, unsigned char *buf,int len)
{
int i;