pe*alloc
[m6w6/ext-psi] / src / types / number.c
index e877e4089d176401daff56d0adfebf7de29be4ee..54831964b9fc98468baf517035f80ff44d0514e6 100644 (file)
@@ -39,7 +39,7 @@
 
 struct psi_number *psi_number_init(token_t t, void *num, unsigned flags)
 {
-       struct psi_number *exp = calloc(1, sizeof(*exp));
+       struct psi_number *exp = pecalloc(1, sizeof(*exp), 1);
 
        exp->flags = flags;
        switch (exp->type = t) {
@@ -104,7 +104,7 @@ struct psi_number *psi_number_init(token_t t, void *num, unsigned flags)
 
 struct psi_number *psi_number_copy(struct psi_number *exp)
 {
-       struct psi_number *num = calloc(1, sizeof(*num));
+       struct psi_number *num = pecalloc(1, sizeof(*num), 1);
 
        *num = *exp;
 
@@ -156,9 +156,7 @@ void psi_number_free(struct psi_number **exp_ptr)
                struct psi_number *exp = *exp_ptr;
 
                *exp_ptr = NULL;
-               if (exp->token) {
-                       free(exp->token);
-               }
+               psi_token_free(&exp->token);
                switch (exp->type) {
                case PSI_T_INT8:
                case PSI_T_UINT8: