@@ -16,16 +16,20 @@ typedef unsigned int uint;
1616
1717/** memomry allocation ******************************************/
1818
19+ // TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)
20+
1921#define m_new (type , num ) ((type*)(m_malloc(sizeof(type) * (num))))
2022#define m_new0 (type , num ) ((type*)(m_malloc0(sizeof(type) * (num))))
21- #define m_renew (type , ptr , num ) ((type*)(m_realloc((ptr), sizeof(type) * (num))))
2223#define m_new_obj (type ) (m_new(type, 1))
2324#define m_new_obj_var (obj_type , var_type , var_num ) ((obj_type*)m_malloc(sizeof(obj_type) + sizeof(var_type) * (var_num)))
25+ #define m_renew (type , ptr , old_num , new_num ) ((type*)(m_realloc((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num))))
26+ #define m_del (type , ptr , num ) m_free(ptr, sizeof(type) * (num))
27+ #define m_del_obj (type , ptr ) (m_del(type, ptr, 1))
2428
25- void m_free (void * ptr );
2629void * m_malloc (int num_bytes );
2730void * m_malloc0 (int num_bytes );
28- void * m_realloc (void * ptr , int num_bytes );
31+ void * m_realloc (void * ptr , int old_num_bytes , int new_num_bytes );
32+ void m_free (void * ptr , int num_bytes );
2933
3034int m_get_total_bytes_allocated (void );
3135
@@ -96,7 +100,7 @@ typedef unsigned int qstr;
96100
97101void qstr_init (void );
98102qstr qstr_from_str_static (const char * str );
99- qstr qstr_from_str_take (char * str );
103+ qstr qstr_from_str_take (char * str , int alloc_len );
100104qstr qstr_from_strn_copy (const char * str , int len );
101105const char * qstr_str (qstr qstr );
102106
0 commit comments