aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-server
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-10 02:21:00 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-10 02:21:00 +0100
commit7179f51176e1f3af53694e09d7ea2ca602403cf1 (patch)
treedb24424529090c7ac819e2ec9724c855dbb2d53e /src/mds-server
parenttypo (diff)
downloadmds-7179f51176e1f3af53694e09d7ea2ca602403cf1.tar.gz
mds-7179f51176e1f3af53694e09d7ea2ca602403cf1.tar.bz2
mds-7179f51176e1f3af53694e09d7ea2ca602403cf1.tar.xz
no more direct allocations, always use macros, unless using alloca
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-server/interception-condition.c2
-rw-r--r--src/mds-server/interceptors.c2
-rw-r--r--src/mds-server/mds-server.c4
-rw-r--r--src/mds-server/receiving.c10
4 files changed, 7 insertions, 11 deletions
diff --git a/src/mds-server/interception-condition.c b/src/mds-server/interception-condition.c
index cfe5d0c..92190af 100644
--- a/src/mds-server/interception-condition.c
+++ b/src/mds-server/interception-condition.c
@@ -71,7 +71,7 @@ size_t interception_condition_unmarshal(interception_condition_t* restrict this,
buf_get_next(data, int64_t, this->priority);
buf_get_next(data, int, this->modifying);
n = (strlen(data) + 1) * sizeof(char);
- fail_if ((this->condition = malloc(n)) == NULL);
+ fail_if (xbmalloc(this->condition, n));
memcpy(this->condition, data, n);
return sizeof(size_t) + sizeof(int64_t) + 2 * sizeof(int) + n;
fail:
diff --git a/src/mds-server/interceptors.c b/src/mds-server/interceptors.c
index 8a24e33..c1dafec 100644
--- a/src/mds-server/interceptors.c
+++ b/src/mds-server/interceptors.c
@@ -140,7 +140,7 @@ void add_intercept_condition(client_t* client, char* condition, int64_t priority
else
{
/* Duplicate condition string. */
- fail_if ((condition = strdup(condition)) == NULL);
+ fail_if (xstrdup(condition, condition));
/* Grow the interception condition list. */
fail_if (xrealloc(conds, n + 1, interception_condition_t));
diff --git a/src/mds-server/mds-server.c b/src/mds-server/mds-server.c
index fabdffa..29caee3 100644
--- a/src/mds-server/mds-server.c
+++ b/src/mds-server/mds-server.c
@@ -429,13 +429,13 @@ void queue_message_multicast(char* message, size_t length, client_t* sender)
char* colon = strchr(msg, ':');
*end = '\0';
- if ((header_values[i] = strdup(msg)) == NULL)
+ if (xstrdup(header_values[i], msg))
{
header_count = i;
fail_if (1);
}
*colon = '\0';
- if ((headers[i] = strdup(msg)) == NULL)
+ if (xstrdup(headers[i], msg))
{
saved_errno = errno, free(headers[i]), errno = saved_errno;
header_count = i;
diff --git a/src/mds-server/receiving.c b/src/mds-server/receiving.c
index 8571944..bc22fe2 100644
--- a/src/mds-server/receiving.c
+++ b/src/mds-server/receiving.c
@@ -82,10 +82,7 @@ static int modifying_notify(client_t* client, mds_message_t message, uint64_t mo
memcpy(multicast->payload, message.payload, message.payload_size * sizeof(char));
fail_if (xmalloc(multicast->headers, message.header_count, char*));
for (i = 0; i < message.header_count; i++, multicast->header_count++)
- {
- multicast->headers[i] = strdup(message.headers[i]);
- fail_if (multicast->headers[i] == NULL);
- }
+ fail_if (xstrdup(multicast->headers[i], message.headers[i]));
done:
pthread_mutex_unlock(&(modify_mutex));
with_mutex (client->modify_mutex, pthread_cond_signal(&(client->modify_cond)););
@@ -199,8 +196,7 @@ static int assign_and_send_id(client_t* client, const char* message_id)
n = strlen(msgbuf);
/* Multicast the reply. */
- msgbuf_ = strdup(msgbuf);
- fail_if (msgbuf_ == NULL);
+ fail_if (xstrdup(msgbuf_, msgbuf));
queue_message_multicast(msgbuf_, n, client);
/* Queue message to be sent when this function returns.
@@ -317,7 +313,7 @@ int message_received(client_t* client)
/* Multicast the message. */
n = mds_message_compose_size(&message);
- fail_if ((msgbuf = malloc(n)) == NULL);
+ fail_if (xbmalloc(msgbuf, n));
mds_message_compose(&message, msgbuf);
queue_message_multicast(msgbuf, n / sizeof(char), client);
msgbuf = NULL;