diff options
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/srv.c | 4 | ||||
-rw-r--r-- | lib9p/tests/test_server/fs_shutdown.c | 4 | ||||
-rw-r--r-- | lib9p/tests/test_server/fs_slowread.c | 4 | ||||
-rw-r--r-- | lib9p/tests/test_server/fs_whoami.c | 6 |
4 files changed, 10 insertions, 8 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 5c50130..a681952 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -4,7 +4,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <alloca.h> #include <inttypes.h> /* for PRI* */ #include <limits.h> /* for SSIZE_MAX, not set by newlib */ #include <stddef.h> /* for size_t */ @@ -17,6 +16,7 @@ #include <libcr/coroutine.h> #include <libcr_ipc/chan.h> #include <libcr_ipc/mutex.h> +#include <libmisc/alloc.h> #include <libmisc/assert.h> #include <libmisc/endian.h> #include <libmisc/map.h> @@ -739,7 +739,7 @@ static void handle_Tversion(struct srv_req *ctx, if (map_len(&ctx->parent_sess->reqs)) { /* Flush all in-progress requests, and wait for them * to finish. */ - struct cr_select_arg *list = alloca(sizeof(struct cr_select_arg) * map_len(&ctx->parent_sess->reqs)); + struct cr_select_arg *list = stack_alloc(map_len(&ctx->parent_sess->reqs), struct cr_select_arg); while (map_len(&ctx->parent_sess->reqs)) { size_t i = 0; bool flushed; diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c index e872b78..e7375ef 100644 --- a/lib9p/tests/test_server/fs_shutdown.c +++ b/lib9p/tests/test_server/fs_shutdown.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <stdlib.h> +#include <libmisc/alloc.h> #include "fs_shutdown.h" @@ -68,7 +68,7 @@ static lo_interface lib9p_srv_fio shutdown_file_fopen(struct shutdown_file *self assert(self); assert(ctx); - struct shutdown_fio *ret = malloc(sizeof(struct shutdown_fio)); + struct shutdown_fio *ret = heap_alloc(1, struct shutdown_fio); ret->parent = self; return lo_box_shutdown_fio_as_lib9p_srv_fio(ret); diff --git a/lib9p/tests/test_server/fs_slowread.c b/lib9p/tests/test_server/fs_slowread.c index c94fba0..4567fef 100644 --- a/lib9p/tests/test_server/fs_slowread.c +++ b/lib9p/tests/test_server/fs_slowread.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <stdlib.h> +#include <libmisc/alloc.h> #include "fs_slowread.h" @@ -68,7 +68,7 @@ static lo_interface lib9p_srv_fio slowread_file_fopen(struct slowread_file *self assert(self); assert(ctx); - struct slowread_fio *ret = malloc(sizeof(struct slowread_fio)); + struct slowread_fio *ret = heap_alloc(1, struct slowread_fio); ret->parent = self; return lo_box_slowread_fio_as_lib9p_srv_fio(ret); diff --git a/lib9p/tests/test_server/fs_whoami.c b/lib9p/tests/test_server/fs_whoami.c index 560e31f..653ac4b 100644 --- a/lib9p/tests/test_server/fs_whoami.c +++ b/lib9p/tests/test_server/fs_whoami.c @@ -5,7 +5,9 @@ */ #include <stdio.h> /* for snprintf() */ -#include <stdlib.h> /* for malloc(), realloc(), free() */ +#include <stdlib.h> /* for realloc(), free() */ + +#include <libmisc/alloc.h> #include "fs_whoami.h" @@ -89,7 +91,7 @@ static lo_interface lib9p_srv_fio whoami_file_fopen(struct whoami_file *self, st assert(self); assert(ctx); - struct whoami_fio *ret = malloc(sizeof(struct whoami_fio)); + struct whoami_fio *ret = heap_alloc(1, struct whoami_fio); ret->parent = self; ret->buf_len = 0; ret->buf = NULL; |