aboutsummaryrefslogtreecommitdiffstats
path: root/smbutil.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2009-05-25 21:59:14 +0000
committerMatthias Andree <matthias.andree@gmx.de>2009-05-25 21:59:14 +0000
commite9792090c892be910c634803b2a3839e061cf4e4 (patch)
treeaeceee1a0bb4357e9a1407e239410954b9a1f147 /smbutil.c
parent4803ed92e3e91cc286a382911f0ec48b92c4cd04 (diff)
downloadfetchmail-e9792090c892be910c634803b2a3839e061cf4e4.tar.gz
fetchmail-e9792090c892be910c634803b2a3839e061cf4e4.tar.bz2
fetchmail-e9792090c892be910c634803b2a3839e061cf4e4.zip
Revise allocbuf to make it a macro, quenches type-aliasing warnings.
svn path=/branches/BRANCH_6-3/; revision=5341
Diffstat (limited to 'smbutil.c')
-rw-r--r--smbutil.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/smbutil.c b/smbutil.c
index 9a8fbeef..18aa1dc4 100644
--- a/smbutil.c
+++ b/smbutil.c
@@ -82,17 +82,16 @@ static void dumpRaw(FILE *fp, unsigned char *buf, size_t len)
fprintf(fp,"\n");
}
-/* helper function to destructively resize buffers; assumes that bufsiz
+/* helper macro to destructively resize buffers; assumes that bufsiz
* is initialized to 0 if buf is unallocated! */
-static void allocbuf(char **buf, size_t *bufsiz, size_t need)
- {
- if (need > *bufsiz)
- {
- *bufsiz = (need < 1024) ? 1024 : need;
- xfree(*buf);
- *buf = xmalloc(*bufsiz);
- }
- }
+#define allocbuf(buf, bufsiz, need) do { \
+ if ((need) > (bufsiz)) \
+ { \
+ (bufsiz) = ((need) < 1024) ? 1024 : (need); \
+ xfree(buf); \
+ (buf) = xmalloc(bufsiz); \
+ } \
+ } while (0);
/* this is a brute-force conversion from UCS-2LE to US-ASCII, discarding
* the upper 9 bits */
@@ -102,7 +101,7 @@ static char *unicodeToString(char *p, size_t len)
static char *buf;
static size_t bufsiz;
- allocbuf(&buf, &bufsiz, len + 1);
+ allocbuf(buf, bufsiz, len + 1);
for (i=0; i<len; ++i)
{
@@ -122,7 +121,7 @@ static unsigned char *strToUnicode(char *p)
size_t l = strlen(p);
int i = 0;
- allocbuf((char **)&buf, &bufsiz, l * 2);
+ allocbuf(buf, bufsiz, l * 2);
while (l--)
{
@@ -138,7 +137,7 @@ static unsigned char *toString(char *p, size_t len)
static unsigned char *buf;
static size_t bufsiz;
- allocbuf((char **)&buf, &bufsiz, len + 1);
+ allocbuf(buf, bufsiz, len + 1);
memcpy(buf,p,len);
buf[len] = 0;