summaryrefslogtreecommitdiffstats
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
commit7969f4dccbc5a506ef58b9270a08f8f70d9006f7 (patch)
tree786a53501f93d592c4b26f164402efa1b1c54067
parent1682faa1b0e95fc5acdf9b10da80a6515f8772cd (diff)
downloadsamba-7969f4dccbc5a506ef58b9270a08f8f70d9006f7.tar.gz
samba-7969f4dccbc5a506ef58b9270a08f8f70d9006f7.tar.xz
samba-7969f4dccbc5a506ef58b9270a08f8f70d9006f7.zip
add an align4() function
-rw-r--r--source/lib/util.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index ebb89c9d899..fdd2b98c562 100644
--- a/source/lib/util.c
+++ b/source/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;