diff --git a/libc3/tag_init.c b/libc3/tag_init.c
index 39763c6..3ce81b1 100644
--- a/libc3/tag_init.c
+++ b/libc3/tag_init.c
@@ -10,8 +10,8 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
+#include "alloc.h"
#include "assert.h"
-#include <string.h>
#include "array.h"
#include "buf.h"
#include "buf_inspect.h"
@@ -519,12 +519,9 @@ s_tag * tag_new_array (const s_sym *type, uw dimension,
const uw *dimensions)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_array: failed to allocate memory");
- assert(! "tag_new_array: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_ARRAY;
if (! array_init(&tag->data.array, type, dimension, dimensions)) {
free(tag);
@@ -536,12 +533,9 @@ s_tag * tag_new_array (const s_sym *type, uw dimension,
s_tag * tag_new_array_copy (const s_array *a)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_array_copy: failed to allocate memory");
- assert(! "tag_new_array_copy: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_ARRAY;
if (! array_init_copy(&tag->data.array, a)) {
free(tag);
@@ -553,12 +547,9 @@ s_tag * tag_new_array_copy (const s_array *a)
s_tag * tag_new_bool (bool b)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_bool: failed to allocate memory");
- assert(! "tag_new_bool: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_BOOL;
tag->data.bool = b;
return tag;
@@ -567,12 +558,9 @@ s_tag * tag_new_bool (bool b)
s_tag * tag_new_call (void)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_call: failed to allocate memory");
- assert(! "tag_new_call: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_CALL;
if (! call_init(&tag->data.call)) {
free(tag);
@@ -584,12 +572,9 @@ s_tag * tag_new_call (void)
s_tag * tag_new_character (character c)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_character: failed to allocate memory");
- assert(! "tag_new_character: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_CHARACTER;
tag->data.character = c;
return tag;
@@ -598,12 +583,9 @@ s_tag * tag_new_character (character c)
s_tag * tag_new_f32 (f32 f)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_f32: failed to allocate memory");
- assert(! "tag_new_f32: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_F32;
tag->data.f32 = f;
return tag;
@@ -612,12 +594,9 @@ s_tag * tag_new_f32 (f32 f)
s_tag * tag_new_f64 (f64 f)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_f64: failed to allocate memory");
- assert(! "tag_new_f64: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_F64;
tag->data.f64 = f;
return tag;
@@ -626,12 +605,9 @@ s_tag * tag_new_f64 (f64 f)
s_tag * tag_new_f128 (f128 f)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_f128: failed to allocate memory");
- assert(! "tag_new_f128: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_F128;
tag->data.f128 = f;
return tag;
@@ -640,12 +616,9 @@ s_tag * tag_new_f128 (f128 f)
s_tag * tag_new_ident (const s_ident *ident)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ident: failed to allocate memory");
- assert(! "tag_new_ident: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_IDENT;
tag->data.ident = *ident;
return tag;
@@ -654,12 +627,9 @@ s_tag * tag_new_ident (const s_ident *ident)
s_tag * tag_new_ident_1 (const char *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ident_1: failed to allocate memory");
- assert(! "tag_new_ident_1: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_IDENT;
if (! ident_init_1(&tag->data.ident, p)) {
free(tag);
@@ -671,12 +641,9 @@ s_tag * tag_new_ident_1 (const char *p)
s_tag * tag_new_integer_1 (const char *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_integer_1: failed to allocate memory");
- assert(! "tag_new_integer_1: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_INTEGER;
if (! integer_init_1(&tag->data.integer, p)) {
free(tag);
@@ -688,12 +655,9 @@ s_tag * tag_new_integer_1 (const char *p)
s_tag * tag_new_integer_copy (const s_integer *i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_integer_copy: failed to allocate memory");
- assert(! "tag_new_integer_copy: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_INTEGER;
if (! integer_init_copy(&tag->data.integer, i)) {
free(tag);
@@ -705,12 +669,9 @@ s_tag * tag_new_integer_copy (const s_integer *i)
s_tag * tag_new_integer_zero (void)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_integer_zero: failed to allocate memory");
- assert(! "tag_new_integer_zero: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_INTEGER;
if (! integer_init_zero(&tag->data.integer)) {
free(tag);
@@ -722,12 +683,9 @@ s_tag * tag_new_integer_zero (void)
s_tag * tag_new_list (s_list *list)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_list: failed to allocate memory");
- assert(! "tag_new_list: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_LIST;
tag->data.list = list;
return tag;
@@ -736,12 +694,9 @@ s_tag * tag_new_list (s_list *list)
s_tag * tag_new_map (uw count)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_map: failed to allocate memory");
- assert(! "tag_new_map: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_MAP;
if (! map_init(&tag->data.map, count)) {
free(tag);
@@ -753,12 +708,9 @@ s_tag * tag_new_map (uw count)
s_tag * tag_new_map_1 (const char *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_map_1: failed to allocate memory");
- assert(! "tag_new_map_1: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_MAP;
if (! map_init_1(&tag->data.map, p)) {
free(tag);
@@ -770,12 +722,9 @@ s_tag * tag_new_map_1 (const char *p)
s_tag * tag_new_ptr (void *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ptr: failed to allocate memory");
- assert(! "tag_new_ptr: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_PTR;
if (! ptr_init(&tag->data.ptr, p)) {
free(tag);
@@ -787,12 +736,9 @@ s_tag * tag_new_ptr (void *p)
s_tag * tag_new_ptr_free (void *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ptr_free: failed to allocate memory");
- assert(! "tag_new_ptr_free: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_PTR_FREE;
if (! ptr_free_init(&tag->data.ptr_free, p)) {
free(tag);
@@ -804,12 +750,9 @@ s_tag * tag_new_ptr_free (void *p)
s_tag * tag_new_quote_copy (const s_quote *quote)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_quote_copy: failed to allocate memory");
- assert(! "tag_new_quote_copy: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_QUOTE;
if (! quote_init_copy(&tag->data.quote, quote)) {
free(tag);
@@ -821,12 +764,9 @@ s_tag * tag_new_quote_copy (const s_quote *quote)
s_tag * tag_new_ratio_1 (const char *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ratio_1: failed to allocate memory");
- assert(! "tag_new_ratio_1: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_RATIO;
if (! ratio_init_1(&tag->data.ratio, p)) {
free(tag);
@@ -838,12 +778,9 @@ s_tag * tag_new_ratio_1 (const char *p)
s_tag * tag_new_ratio (void)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ratio: failed to allocate memory");
- assert(! "tag_new_ratio: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_RATIO;
if (! ratio_init(&tag->data.ratio)) {
free(tag);
@@ -855,12 +792,9 @@ s_tag * tag_new_ratio (void)
s_tag * tag_new_ratio_copy (const s_ratio *r)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ratio_copy: failed to allocate memory");
- assert(! "tag_new_ratio_copy: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_RATIO;
if (! ratio_init_copy(&tag->data.ratio, r)) {
free(tag);
@@ -872,12 +806,9 @@ s_tag * tag_new_ratio_copy (const s_ratio *r)
s_tag * tag_new_ratio_zero (void)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_ratio_zero: failed to allocate memory");
- assert(! "tag_new_ratio_zero: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_RATIO;
if (! ratio_init_zero(&tag->data.ratio)) {
free(tag);
@@ -889,12 +820,9 @@ s_tag * tag_new_ratio_zero (void)
s_tag * tag_new_s8 (s8 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_s8: failed to allocate memory");
- assert(! "tag_new_s8: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_S8;
tag->data.s8 = i;
return tag;
@@ -903,12 +831,9 @@ s_tag * tag_new_s8 (s8 i)
s_tag * tag_new_s16 (s16 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_s16: failed to allocate memory");
- assert(! "tag_new_s16: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_S16;
tag->data.s16 = i;
return tag;
@@ -917,12 +842,9 @@ s_tag * tag_new_s16 (s16 i)
s_tag * tag_new_s32 (s32 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_s32: failed to allocate memory");
- assert(! "tag_new_s32: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_S32;
tag->data.s32 = i;
return tag;
@@ -931,12 +853,9 @@ s_tag * tag_new_s32 (s32 i)
s_tag * tag_new_s64 (s64 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_s64: failed to allocate memory");
- assert(! "tag_new_s64: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_S64;
tag->data.s64 = i;
return tag;
@@ -945,12 +864,9 @@ s_tag * tag_new_s64 (s64 i)
s_tag * tag_new_str (char *p_free, uw size, const char *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_str: failed to allocate memory");
- assert(! "tag_new_str: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_STR;
if (! str_init(&tag->data.str, p_free, size, p)) {
free(tag);
@@ -962,12 +878,9 @@ s_tag * tag_new_str (char *p_free, uw size, const char *p)
s_tag * tag_new_str_1 (char *p_free, const char *p)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_str_1: failed to allocate memory");
- assert(! "tag_new_str_1: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_STR;
if (! str_init_1(&tag->data.str, p_free, p)) {
free(tag);
@@ -979,12 +892,9 @@ s_tag * tag_new_str_1 (char *p_free, const char *p)
s_tag * tag_new_str_cat (const s_str *a, const s_str *b)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_str_cat: failed to allocate memory");
- assert(! "tag_new_str_cat: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_STR;
if (! str_init_cat(&tag->data.str, a, b)) {
free(tag);
@@ -996,12 +906,9 @@ s_tag * tag_new_str_cat (const s_str *a, const s_str *b)
s_tag * tag_new_str_empty (void)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_str_empty: failed to allocate memory");
- assert(! "tag_new_str_empty: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_STR;
if (! str_init_empty(&tag->data.str)) {
free(tag);
@@ -1013,12 +920,9 @@ s_tag * tag_new_str_empty (void)
s_tag * tag_new_struct (const s_sym *module)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_struct: failed to allocate memory");
- assert(! "tag_new_struct: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_STRUCT;
if (! struct_init(&tag->data.struct_, module)) {
free(tag);
@@ -1031,12 +935,9 @@ s_tag * tag_new_struct_with_data (const s_sym *module, bool free_data,
void *data)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_struct_with_data: failed to allocate memory");
- assert(! "tag_new_struct_with_data: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_STRUCT;
if (! struct_init_with_data(&tag->data.struct_, module, free_data,
data)) {
@@ -1049,12 +950,9 @@ s_tag * tag_new_struct_with_data (const s_sym *module, bool free_data,
s_tag * tag_new_sw (sw i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_sw: failed to allocate memory");
- assert(! "tag_new_sw: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_SW;
tag->data.sw = i;
return tag;
@@ -1063,12 +961,9 @@ s_tag * tag_new_sw (sw i)
s_tag * tag_new_sym (const s_sym *sym)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_sym: failed to allocate memory");
- assert(! "tag_new_sym: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_SYM;
tag->data.sym = sym;
return tag;
@@ -1077,12 +972,9 @@ s_tag * tag_new_sym (const s_sym *sym)
s_tag * tag_new_tuple (uw count)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_tuple: failed to allocate memory");
- assert(! "tag_new_tuple: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_TUPLE;
if (! tuple_init(&tag->data.tuple, count)) {
free(tag);
@@ -1094,12 +986,9 @@ s_tag * tag_new_tuple (uw count)
s_tag * tag_new_tuple_2 (const s_tag *a, const s_tag *b)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_tuple_2: failed to allocate memory");
- assert(! "tag_new_tuple_2: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_TUPLE;
if (! tuple_init_2(&tag->data.tuple, a, b)) {
free(tag);
@@ -1111,12 +1000,9 @@ s_tag * tag_new_tuple_2 (const s_tag *a, const s_tag *b)
s_tag * tag_new_u8 (u8 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_u8: failed to allocate memory");
- assert(! "tag_new_u8: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_U8;
tag->data.u8 = i;
return tag;
@@ -1125,12 +1011,9 @@ s_tag * tag_new_u8 (u8 i)
s_tag * tag_new_u16 (u16 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_u16: failed to allocate memory");
- assert(! "tag_new_u16: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_U16;
tag->data.u16 = i;
return tag;
@@ -1139,12 +1022,9 @@ s_tag * tag_new_u16 (u16 i)
s_tag * tag_new_u32 (u32 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_u32: failed to allocate memory");
- assert(! "tag_new_u32: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_U32;
tag->data.u32 = i;
return tag;
@@ -1153,12 +1033,9 @@ s_tag * tag_new_u32 (u32 i)
s_tag * tag_new_u64 (u64 i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_u64: failed to allocate memory");
- assert(! "tag_new_u64: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_U64;
tag->data.u64 = i;
return tag;
@@ -1167,12 +1044,9 @@ s_tag * tag_new_u64 (u64 i)
s_tag * tag_new_unquote_copy (const s_unquote *unquote)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_unquote_copy: failed to allocate memory");
- assert(! "tag_new_unquote_copy: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_UNQUOTE;
if (! unquote_init_copy(&tag->data.unquote, unquote)) {
free(tag);
@@ -1184,12 +1058,9 @@ s_tag * tag_new_unquote_copy (const s_unquote *unquote)
s_tag * tag_new_uw (uw i)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_uw: failed to allocate memory");
- assert(! "tag_new_uw: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_UW;
tag->data.uw = i;
return tag;
@@ -1198,12 +1069,9 @@ s_tag * tag_new_uw (uw i)
s_tag * tag_new_var (void)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_var: failed to allocate memory");
- assert(! "tag_new_var: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_VAR;
return tag;
}
@@ -1211,12 +1079,9 @@ s_tag * tag_new_var (void)
s_tag * tag_new_void (void)
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_void: failed to allocate memory");
- assert(! "tag_new_void: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
tag->type = TAG_VOID;
return tag;
}
diff --git a/libc3/tag_init.rb b/libc3/tag_init.rb
index 6228794..c1dada4 100644
--- a/libc3/tag_init.rb
+++ b/libc3/tag_init.rb
@@ -167,12 +167,9 @@ EOF
#{tag_new_proto[0..-2]}
{
s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- if (! tag) {
- err_puts("tag_new_#{name_suffix}: failed to allocate memory");
- assert(! "tag_new_#{name_suffix}: failed to allocate memory");
+ tag = alloc(sizeof(s_tag));
+ if (! tag)
return NULL;
- }
#{tag_type ? "tag->type = #{tag_type};\n" : ""}#{def_tag_new_init} return tag;
}
EOF
@@ -506,8 +503,8 @@ inits = TagInitList.all
tag_init_c = FileUpdate.new("tag_init.c")
tag_init_c.content = <<EOF
#{$license}
+#include "alloc.h"
#include "assert.h"
-#include <string.h>
#include "array.h"
#include "buf.h"
#include "buf_inspect.h"