summaryrefslogtreecommitdiffstats
path: root/lib/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/server.c')
-rw-r--r--lib/server.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/server.c b/lib/server.c
index 6229ecd..6a67395 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -8,6 +8,7 @@
#include <pthread.h>
#include <string.h>
+#include <alloca.h>
#include "private.h"
#include "protocol.h"
@@ -69,7 +70,7 @@ static bool handle_message(
if (!icipc_protocol_parse_request(buffer, size, &name, &args)) {
const char *msg = "could not parse request";
const size_t s = icipc_protocol_calculate_reply_error_size(msg);
- uint8_t b[s];
+ uint8_t *b = alloca(s);
icipc_protocol_build_reply_error(b, s, msg);
return icipc_socket_write(sender_fd, b, s) == (ssize_t) s;
}
@@ -234,7 +235,7 @@ bool icipc_server_reply_ok(
int client_fd,
const struct icipc_data *value) {
const size_t s = icipc_protocol_calculate_reply_ok_size(value);
- uint8_t b[s];
+ uint8_t *b = alloca(s);
icipc_protocol_build_reply_ok(b, s, value);
return icipc_socket_write(client_fd, b, s) == (ssize_t) s;
}
@@ -247,7 +248,7 @@ bool icipc_server_reply_error(
return false;
const size_t s = icipc_protocol_calculate_reply_error_size(msg);
- uint8_t b[s];
+ uint8_t *b = alloca(s);
icipc_protocol_build_reply_error(b, s, msg);
return icipc_socket_write(client_fd, b, s) == (ssize_t) s;
}