diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-10 02:58:25 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-10 02:58:25 +0100 |
commit | 344273a7e0a6899451836e6072fecebea4a6ac24 (patch) | |
tree | ea24fa9e12ae6dad40eeb6470c92545e14f0f8cf /src/libmdsserver/mds-message.c | |
parent | no more direct allocations, always use macros, unless using alloca (diff) | |
download | mds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.gz mds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.bz2 mds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.xz |
add xmemdup macro
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsserver/mds-message.c')
-rw-r--r-- | src/libmdsserver/mds-message.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/libmdsserver/mds-message.c b/src/libmdsserver/mds-message.c index 5007f23..1676023 100644 --- a/src/libmdsserver/mds-message.c +++ b/src/libmdsserver/mds-message.c @@ -254,7 +254,7 @@ static int store_header(mds_message_t* restrict this, size_t length) char* header; /* Allocate the header. */ - fail_if (xmalloc(header, length, char)); + fail_if (xmalloc(header, length, char)); /* FIXME this do not feel right (but it works perfectly...) */ /* Copy the header data into the allocated header, */ memcpy(header, this->buffer, length * sizeof(char)); /* and NUL-terminate it. */ @@ -530,8 +530,7 @@ int mds_message_unmarshal(mds_message_t* restrict this, char* restrict data) for (i = 0; i < this->header_count; i++) { n = strlen(data) + 1; - fail_if (xmalloc(this->headers[i], n, char)); - memcpy(this->headers[i], data, n * sizeof(char)); + fail_if (xmemdup(this->headers[i], data, n, char)); buf_next(data, char, n); this->header_count++; } |