From db9a58f48c6eae16fbfcd89d59b09e123dbed54f Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 15 Apr 2025 15:58:31 -0600 Subject: libmisc: Add alloc.h to help detect wrong alloc sizes Lo and behold, there was a mistake in chan.c. --- lib9p/tests/test_server/fs_shutdown.c | 4 ++-- lib9p/tests/test_server/fs_slowread.c | 4 ++-- lib9p/tests/test_server/fs_whoami.c | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'lib9p/tests') 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 +#include #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 +#include #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 /* for snprintf() */ -#include /* for malloc(), realloc(), free() */ +#include /* for realloc(), free() */ + +#include #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; -- cgit v1.2.3-2-g168b