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/mds-registry | |
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 '')
-rw-r--r-- | src/mds-registry/registry.c | 3 | ||||
-rw-r--r-- | src/mds-registry/slave.c | 21 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/mds-registry/registry.c b/src/mds-registry/registry.c index b13c7b4..4a35975 100644 --- a/src/mds-registry/registry.c +++ b/src/mds-registry/registry.c @@ -383,7 +383,8 @@ static int list_registry(const char* recv_client_id, const char* recv_message_id /* Send message. */ fail_if (full_send(send_buffer + ptr, strlen(send_buffer + ptr))); - return full_send(send_buffer, ptr); + fail_if (full_send(send_buffer, ptr)); + return 0; fail: return -1; } diff --git a/src/mds-registry/slave.c b/src/mds-registry/slave.c index 5e496f5..a8a23b6 100644 --- a/src/mds-registry/slave.c +++ b/src/mds-registry/slave.c @@ -431,15 +431,13 @@ size_t slave_unmarshal(slave_t* restrict this, char* restrict data) buf_get_next(data, time_t, this->dethklok.tv_sec); buf_get_next(data, long, this->dethklok.tv_nsec); - n = (strlen((char*)data) + 1) * sizeof(char); - fail_if (xbmalloc(this->client_id, n)); - memcpy(this->client_id, data, n); - data += n, rc += n; + n = strlen((char*)data) + 1; + fail_if (xmemdup(this->client_id, data, n, char)); + data += n, rc += n * sizeof(char); - n = (strlen((char*)data) + 1) * sizeof(char); - fail_if (xbmalloc(this->message_id, n)); - memcpy(this->message_id, data, n); - data += n, rc += n; + n = strlen((char*)data) + 1; + fail_if (xmemdup(this->message_id, data, n, char)); + data += n, rc += n * sizeof(char); fail_if (xmalloc(this->wait_set, 1, hash_table_t)); fail_if (hash_table_create(this->wait_set)); @@ -448,10 +446,9 @@ size_t slave_unmarshal(slave_t* restrict this, char* restrict data) while (m--) { - n = (strlen((char*)data) + 1) * sizeof(char); - fail_if (xbmalloc(protocol, n)); - memcpy(protocol, data, n); - data += n, rc += n; + n = strlen((char*)data) + 1; + fail_if (xmemdup(protocol, data, n, char)); + data += n, rc += n * sizeof(char); key = (size_t)(void*)protocol; if (hash_table_put(this->wait_set, key, 1) == 0) |