aboutsummaryrefslogtreecommitdiff
path: root/src_c
diff options
context:
space:
mode:
Diffstat (limited to 'src_c')
-rw-r--r--src_c/common.c3
-rw-r--r--src_c/main.c5
-rw-r--r--src_c/pool.c8
3 files changed, 7 insertions, 9 deletions
diff --git a/src_c/common.c b/src_c/common.c
index 066ff5a..01df99b 100644
--- a/src_c/common.c
+++ b/src_c/common.c
@@ -406,8 +406,7 @@ int opcut_params_init(hat_allocator_t *a, opcut_params_t *params,
if (tokens_len < 0)
return OPCUT_ERROR;
- jsmntok_t *tokens =
- hat_allocator_alloc(a, tokens_len * sizeof(jsmntok_t), NULL);
+ jsmntok_t *tokens = hat_allocator_alloc(a, tokens_len * sizeof(jsmntok_t));
if (!tokens)
return OPCUT_ERROR;
diff --git a/src_c/main.c b/src_c/main.c
index 5532de0..d49db74 100644
--- a/src_c/main.c
+++ b/src_c/main.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <argparse.h>
+#include <hat/libc_allocator.h>
#include "csp.h"
@@ -64,7 +65,7 @@ static int read_stream(hat_allocator_t *a, FILE *stream, opcut_str_t *json) {
while (!(json->len < size)) {
size += 4096;
- char *data = hat_allocator_alloc(a, size, json->data);
+ char *data = hat_allocator_realloc(a, size, json->data);
if (!data)
return OPCUT_ERROR;
@@ -77,7 +78,7 @@ static int read_stream(hat_allocator_t *a, FILE *stream, opcut_str_t *json) {
int main(int argc, char **argv) {
- hat_allocator_t *a = &hat_allocator_libc;
+ hat_allocator_t *a = &hat_libc_allocator;
opcut_pool_t *panel_pool = opcut_pool_create(a, sizeof(opcut_panel_t));
opcut_pool_t *item_pool = opcut_pool_create(a, sizeof(opcut_item_t));
opcut_pool_t *used_pool = opcut_pool_create(a, sizeof(opcut_used_t));
diff --git a/src_c/pool.c b/src_c/pool.c
index 7e2bd02..4bd8250 100644
--- a/src_c/pool.c
+++ b/src_c/pool.c
@@ -25,10 +25,8 @@ static void allocate_block(opcut_pool_t *pool) {
items_per_block = 1;
header_t *block = hat_allocator_alloc(
- pool->a,
- sizeof(header_t) +
- items_per_block * (sizeof(header_t) + pool->item_size),
- NULL);
+ pool->a, sizeof(header_t) +
+ items_per_block * (sizeof(header_t) + pool->item_size));
if (!block)
return;
block->next = pool->blocks;
@@ -44,7 +42,7 @@ static void allocate_block(opcut_pool_t *pool) {
opcut_pool_t *opcut_pool_create(hat_allocator_t *a, size_t item_size) {
- opcut_pool_t *pool = hat_allocator_alloc(a, sizeof(opcut_pool_t), NULL);
+ opcut_pool_t *pool = hat_allocator_alloc(a, sizeof(opcut_pool_t));
if (!pool)
return NULL;