diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2021-07-09 13:35:36 +0300 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2021-07-28 13:19:02 +0300 |
commit | 404fcb1c102af07a6760a80fa994d20e9a4de7f7 (patch) | |
tree | 2327297df8b87204726d703da74fe49935cdd238 /lib/server.c | |
parent | d61cc219f6bd3c4ffc96239893a8ded9b5a83b30 (diff) |
lib: avoid static buffers, use alloca() more
Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
Diffstat (limited to 'lib/server.c')
-rw-r--r-- | lib/server.c | 7 |
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; } |