summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eval.c2
-rw-r--r--identifiers.c2
-rw-r--r--tokenizer.c2
-rw-r--r--types.c2
-rw-r--r--util/arr.c2
-rw-r--r--util/blockarr.c2
6 files changed, 6 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 071ca3f..c6a659a 100644
--- a/eval.c
+++ b/eval.c
@@ -47,7 +47,7 @@ static bool eval_expr(Expression *e, Value *v) {
return true;
}
case UNARY_ADDRESS:
- v->points_to = malloc(sizeof *v->points_to); /* OPTIM */
+ v->points_to = err_malloc(sizeof *v->points_to); /* OPTIM */
return eval_expr(e->unary.of, v->points_to);
case UNARY_DEREF: {
Value ptr;
diff --git a/identifiers.c b/identifiers.c
index 6e993f2..168bf7b 100644
--- a/identifiers.c
+++ b/identifiers.c
@@ -162,7 +162,7 @@ static Identifier ident_get(Identifiers *ids, const char *s) {
static char *ident_to_str(Identifier i) {
size_t i_len = (size_t)(i->depth / 2); /* length = depth / 2 */
- char *str = malloc(i_len + 1);
+ char *str = err_malloc(i_len + 1);
str += i_len;
*str = 0;
while (i->parent) {
diff --git a/tokenizer.c b/tokenizer.c
index 87a6a95..96f62e0 100644
--- a/tokenizer.c
+++ b/tokenizer.c
@@ -530,7 +530,7 @@ static bool tokenize_string(Tokenizer *t, char *str) {
len++;
tokr_nextchar(t);
}
- char *strlit = malloc(len + 1);
+ char *strlit = err_malloc(len + 1);
char *strptr = strlit;
tokr_get_location(t, token);
tokr_nextchar(t); /* past opening " */
diff --git a/types.c b/types.c
index 51a801f..ad98da1 100644
--- a/types.c
+++ b/types.c
@@ -463,7 +463,7 @@ static bool type_of_expr(Typer *tr, Expression *e) {
return false;
}
t->kind = TYPE_PTR;
- t->ptr.of = malloc(sizeof *t->ptr.of); /* OPTIM */
+ t->ptr.of = err_malloc(sizeof *t->ptr.of); /* OPTIM */
*t->ptr.of = *of_type;
break;
case UNARY_DEREF:
diff --git a/util/arr.c b/util/arr.c
index 63423c0..e3f5b8c 100644
--- a/util/arr.c
+++ b/util/arr.c
@@ -13,7 +13,7 @@ static void arr_create(Array *arr, size_t item_sz) {
static inline void arr_reserve(Array *arr, size_t n) {
arr->cap = n;
- arr->data = realloc(arr->data, arr->item_sz * arr->cap);
+ arr->data = err_realloc(arr->data, arr->item_sz * arr->cap);
}
diff --git a/util/blockarr.c b/util/blockarr.c
index 03d44b2..bdbffd3 100644
--- a/util/blockarr.c
+++ b/util/blockarr.c
@@ -36,7 +36,7 @@ static void *block_arr_add(BlockArr *arr) {
ArrBlock *block;
/* no blocks yet / ran out of blocks*/
block = arr_add(&arr->blocks);
- block->data = malloc(arr->item_sz << arr->lg_block_sz);
+ block->data = err_malloc(arr->item_sz << arr->lg_block_sz);
block->n = 1;
block->last = block->data;
return block->data;