X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Ftypes%2Fcpp_macro_call.c;h=e1277ca9640f9215e212d525a95422f38b2ed193;hp=0df9adbbbca8037add029de607dd616d88473215;hb=a7ac1c0a3c855321f21682c127a4b707de33a303;hpb=6509a2053456d0e63b6f383b757289d3016ed1a5 diff --git a/src/types/cpp_macro_call.c b/src/types/cpp_macro_call.c index 0df9adb..e1277ca 100644 --- a/src/types/cpp_macro_call.c +++ b/src/types/cpp_macro_call.c @@ -28,11 +28,11 @@ #include "cpp.h" #include "data.h" -struct psi_cpp_macro_call *psi_cpp_macro_call_init(const char *name, +struct psi_cpp_macro_call *psi_cpp_macro_call_init(zend_string *name, struct psi_plist *args) { - struct psi_cpp_macro_call *call = calloc(1, sizeof(*call)); - call->name = strdup(name); + struct psi_cpp_macro_call *call = pecalloc(1, sizeof(*call), 1); + call->name = zend_string_copy(name); call->args = args; return call; } @@ -40,14 +40,14 @@ struct psi_cpp_macro_call *psi_cpp_macro_call_init(const char *name, struct psi_cpp_macro_call *psi_cpp_macro_call_copy( struct psi_cpp_macro_call *call) { - struct psi_cpp_macro_call *copy = calloc(1, sizeof(*copy)); - copy->name = strdup(call->name); + struct psi_cpp_macro_call *copy = pecalloc(1, sizeof(*copy), 1); + copy->name = zend_string_copy(call->name); if (call->token) { copy->token = psi_token_copy(call->token); } if (call->args) { copy->args = psi_plist_copy(call->args, - (void (*)(void*)) psi_token_copy_ctor); + (void (*)(void*)) psi_num_exp_copy_ctor); } return copy; } @@ -59,14 +59,26 @@ void psi_cpp_macro_call_free(struct psi_cpp_macro_call **call_ptr) *call_ptr = NULL; - free(call->name); + zend_string_release(call->name); if (call->args) { psi_plist_free(call->args); } - if (call->token) { - free(call->token); - } + psi_token_free(&call->token); free(call); } } +void psi_cpp_macro_call_dump(int fd, struct psi_cpp_macro_call *call) +{ + size_t i = 0; + struct psi_num_exp *num; + + dprintf(fd, "%s(", call->name->val); + while (psi_plist_get(call->args, i++, &num)) { + if (i > 1) { + dprintf(fd, ", "); + } + psi_num_exp_dump(fd, num); + } + dprintf(fd, ")"); +}