[svn:parrot] r48831 - in trunk: src/nci tools/dev
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Tue Sep 7 22:20:30 UTC 2010
Author: chromatic
Date: Tue Sep 7 22:20:30 2010
New Revision: 48831
URL: https://trac.parrot.org/parrot/changeset/48831
Log:
[NCI] Plugged potential NCI STRING leaks.
There are still more leaks lurking here; if the bound function changes where a
char * points, the C string could be lost forever. A true fix will keep around
a pointer to the allocated string and free that, rather than hoping that it'll
survive mangling elsewhere.
Modified:
trunk/src/nci/extra_thunks.c
trunk/tools/dev/nci_thunk_gen.pir
Modified: trunk/src/nci/extra_thunks.c
==============================================================================
--- trunk/src/nci/extra_thunks.c Tue Sep 7 22:20:26 2010 (r48830)
+++ trunk/src/nci/extra_thunks.c Tue Sep 7 22:20:30 2010 (r48831)
@@ -20,7 +20,7 @@
* References:
*/
-
+#define PARROT_IN_EXTENSION
#include "parrot/parrot.h"
#include "pmc/pmc_nci.h"
@@ -200,7 +200,7 @@
fn_pointer = (func_t)D2FPTR(orig_func);
return_data = (int)(*fn_pointer)(t_0, PMC_IS_NULL((PMC*)t_1) ? (void *)NULL : VTABLE_get_pointer(interp, t_1));
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
@@ -304,7 +304,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
@@ -353,7 +353,7 @@
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
pcf_v_p(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -399,7 +399,7 @@
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_v_ptt(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -423,8 +423,8 @@
(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_v_Jtiiipt(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -451,12 +451,12 @@
(*fn_pointer)(interp, t_1, t_2, t_3, t_4, PMC_IS_NULL((PMC*)t_5) ? (void *)NULL : VTABLE_get_pointer(interp, t_5), t_6);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
-if (t_6) Parrot_str_free_cstring(t_6);
+if (!STRING_IS_NULL(ts_6)) Parrot_str_free_cstring(t_6);
}
static void
pcf_p_JttPP(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -486,8 +486,8 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
@@ -513,7 +513,7 @@
return_data = (PMC *)(*fn_pointer)(interp, t_1, PMC_IS_NULL((PMC*)t_2) ? (void *)NULL : VTABLE_get_pointer(interp, t_2), t_3);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
@@ -591,7 +591,7 @@
(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
pcf_v_Jpt(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -615,7 +615,7 @@
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_v_(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -1375,7 +1375,7 @@
return_data = (int)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2, t_3);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
@@ -1431,8 +1431,8 @@
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
@@ -1459,7 +1459,7 @@
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
@@ -1488,9 +1488,9 @@
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
-if (t_3) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
}
static void
@@ -1648,8 +1648,8 @@
return_data = (char *)(*fn_pointer)(t_0, t_1);
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
-if (t_1) Parrot_str_free_cstring(t_1);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
pcf_I_JOt(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -1673,7 +1673,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_v_JOSI(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2033,8 +2033,8 @@
return_data = (long)(*fn_pointer)(t_0, t_1, t_2, t_3);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
@@ -2229,11 +2229,11 @@
return_data = (int)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2, t_3, t_4, t_5);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
-if (t_3) Parrot_str_free_cstring(t_3);
-if (t_4) Parrot_str_free_cstring(t_4);
-if (t_5) Parrot_str_free_cstring(t_5);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_4)) Parrot_str_free_cstring(t_4);
+if (!STRING_IS_NULL(ts_5)) Parrot_str_free_cstring(t_5);
}
static void
pcf_c_pttt(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2258,9 +2258,9 @@
return_data = (char)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2, t_3);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
-if (t_3) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
}
static void
pcf_p_pttttiti(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2294,12 +2294,12 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
-if (t_3) Parrot_str_free_cstring(t_3);
-if (t_4) Parrot_str_free_cstring(t_4);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_4)) Parrot_str_free_cstring(t_4);
-if (t_6) Parrot_str_free_cstring(t_6);
+if (!STRING_IS_NULL(ts_6)) Parrot_str_free_cstring(t_6);
}
static void
@@ -2323,7 +2323,7 @@
return_data = (int)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
pcf_i_ptl(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2347,7 +2347,7 @@
return_data = (int)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
@@ -2441,7 +2441,7 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
pcf_p_ptt(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2470,8 +2470,8 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_i_pit(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2496,7 +2496,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_p_pp(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2547,8 +2547,8 @@
fn_pointer = (func_t)D2FPTR(orig_func);
return_data = (long)(*fn_pointer)(t_0, t_1, t_2);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
- if (t_0) Parrot_str_free_cstring(t_0);
-if (t_1) Parrot_str_free_cstring(t_1);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
@@ -2574,8 +2574,8 @@
return_data = (long)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2, t_3);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
@@ -2597,7 +2597,7 @@
fn_pointer = (func_t)D2FPTR(orig_func);
(*fn_pointer)(t_0);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
pcf_p_pttttitl(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -2631,12 +2631,12 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
-if (t_3) Parrot_str_free_cstring(t_3);
-if (t_4) Parrot_str_free_cstring(t_4);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_4)) Parrot_str_free_cstring(t_4);
-if (t_6) Parrot_str_free_cstring(t_6);
+if (!STRING_IS_NULL(ts_6)) Parrot_str_free_cstring(t_6);
}
static void
@@ -2658,7 +2658,9 @@
PMC * t_4;
UNUSED(return_data); /* Potentially unused, at least */
Parrot_pcc_fill_params_from_c_args(interp, call_object, "SISPP", &ts_0, &t_1, &ts_2, &t_3, &t_4);
- t_0 = STRING_IS_NULL(ts_0) ? (char *)NULL : Parrot_str_to_cstring(interp, ts_0);t_2 = STRING_IS_NULL(ts_2) ? (char *) NULL : Parrot_str_to_cstring(interp, ts_2);i_3 = VTABLE_get_integer(interp, t_3);
+ t_0 = STRING_IS_NULL(ts_0) ? (char *)NULL : Parrot_str_to_cstring(interp, ts_0);
+ t_2 = STRING_IS_NULL(ts_2) ? (char *) NULL : Parrot_str_to_cstring(interp, ts_2);
+ i_3 = VTABLE_get_integer(interp, t_3);
GETATTR_NCI_orig_func(interp, nci, orig_func);
fn_pointer = (func_t)D2FPTR(orig_func);
return_data = (void *)(*fn_pointer)(t_0, t_1, &t_2, &i_3, t_4);
@@ -2667,9 +2669,9 @@
VTABLE_set_pointer(interp, final_destination, return_data);
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) { fprintf( stderr, "Freeing t_0\n" ); Parrot_str_free_cstring(t_0); }
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) { fprintf( stderr, "Freeing t_2\n" ); Parrot_str_free_cstring(t_2); }
VTABLE_set_integer_native(interp, t_3, i_3);
}
@@ -2701,7 +2703,7 @@
VTABLE_set_pointer(interp, final_destination, return_data);
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
VTABLE_set_integer_native(interp, t_3, i_3);
@@ -2735,7 +2737,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
@@ -2766,7 +2768,7 @@
fn_pointer = (func_t)D2FPTR(orig_func);
return_data = (int)(*fn_pointer)(t_0, PMC_IS_NULL((PMC*)t_1) ? (void *)NULL : VTABLE_get_pointer(interp, t_1), t_2, t_3, Buffer_bufstart(t_4), t_5);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
@@ -2805,7 +2807,7 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
@@ -2880,8 +2882,8 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
@@ -2916,7 +2918,7 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
@@ -3062,7 +3064,7 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
@@ -3118,7 +3120,7 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
@@ -3147,7 +3149,7 @@
VTABLE_set_pointer(interp, final_destination, return_data);
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
@@ -3177,7 +3179,7 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
@@ -3203,7 +3205,7 @@
return_data = (int)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, &i_2, &i_3);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
VTABLE_set_integer_native(interp, t_2, i_2);
VTABLE_set_integer_native(interp, t_3, i_3);
}
@@ -3650,7 +3652,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_i_iiti(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -3676,7 +3678,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
@@ -3728,7 +3730,7 @@
return_data = (int)(*fn_pointer)(t_0, t_1, t_2);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
@@ -4261,7 +4263,7 @@
-if (t_3) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
}
static void
pcf_i_piiti(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -4289,7 +4291,7 @@
-if (t_3) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
}
static void
@@ -4621,7 +4623,7 @@
return_data = (int)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
@@ -4648,7 +4650,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
@@ -4818,7 +4820,7 @@
fn_pointer = (func_t)D2FPTR(orig_func);
return_data = (int)(*fn_pointer)(t_0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
pcf_i_ti(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -4840,7 +4842,7 @@
fn_pointer = (func_t)D2FPTR(orig_func);
return_data = (int)(*fn_pointer)(t_0, t_1);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
@@ -5106,7 +5108,7 @@
VTABLE_set_pointer(interp, final_destination, return_data);
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
pcf_p_b(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -5159,7 +5161,7 @@
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
pcf_p_i(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -5411,7 +5413,7 @@
VTABLE_set_pointer(interp, final_destination, return_data);
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
pcf_p_tpp(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -5439,7 +5441,7 @@
VTABLE_set_pointer(interp, final_destination, return_data);
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
@@ -5473,13 +5475,13 @@
VTABLE_set_pointer(interp, final_destination, return_data);
}
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "P", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
-if (t_1) Parrot_str_free_cstring(t_1);
-if (t_2) Parrot_str_free_cstring(t_2);
-if (t_3) Parrot_str_free_cstring(t_3);
-if (t_4) Parrot_str_free_cstring(t_4);
-if (t_5) Parrot_str_free_cstring(t_5);
-if (t_6) Parrot_str_free_cstring(t_6);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_3)) Parrot_str_free_cstring(t_3);
+if (!STRING_IS_NULL(ts_4)) Parrot_str_free_cstring(t_4);
+if (!STRING_IS_NULL(ts_5)) Parrot_str_free_cstring(t_5);
+if (!STRING_IS_NULL(ts_6)) Parrot_str_free_cstring(t_6);
}
static void
pcf_s_(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -5642,7 +5644,7 @@
return_data = (char *)(*fn_pointer)(t_0);
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
pcf_t_tl4(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -5667,7 +5669,7 @@
return_data = (char *)(*fn_pointer)(t_0, t_1, &i_2);
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
VTABLE_set_integer_native(interp, t_2, i_2);
}
@@ -5693,7 +5695,7 @@
return_data = (char *)(*fn_pointer)(t_0, &i_1);
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
VTABLE_set_integer_native(interp, t_1, i_1);
}
static void
@@ -5857,7 +5859,7 @@
return_data = (char *)(*fn_pointer)(&t_0);
final_destination = Parrot_str_new(interp, return_data, 0);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "S", final_destination);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
}
static void
pcf_v_P(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -6069,7 +6071,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_i_Jt(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -6091,7 +6093,7 @@
return_data = (int)(*fn_pointer)(interp, t_1);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
}
static void
pcf_i_Ji(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -6392,7 +6394,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
static void
pcf_i_pppi(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
@@ -6613,7 +6615,7 @@
fn_pointer = (func_t)D2FPTR(orig_func);
return_data = (int)(*fn_pointer)(t_0, &v_1);
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
- if (t_0) Parrot_str_free_cstring(t_0);
+ if (!STRING_IS_NULL(ts_0)) Parrot_str_free_cstring(t_0);
VTABLE_set_pointer(interp, t_1, v_1);
}
static void
@@ -6640,7 +6642,7 @@
return_data = (int)(*fn_pointer)(PMC_IS_NULL((PMC*)t_0) ? (void *)NULL : VTABLE_get_pointer(interp, t_0), t_1, t_2, &v_3, PMC_IS_NULL((PMC*)t_4) ? (void *)NULL : VTABLE_get_pointer(interp, t_4));
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_1) Parrot_str_free_cstring(t_1);
+if (!STRING_IS_NULL(ts_1)) Parrot_str_free_cstring(t_1);
VTABLE_set_pointer(interp, t_3, v_3);
@@ -6695,7 +6697,7 @@
ret_object = Parrot_pcc_build_call_from_c_args(interp, call_object, "I", return_data);
-if (t_2) Parrot_str_free_cstring(t_2);
+if (!STRING_IS_NULL(ts_2)) Parrot_str_free_cstring(t_2);
}
Modified: trunk/tools/dev/nci_thunk_gen.pir
==============================================================================
--- trunk/tools/dev/nci_thunk_gen.pir Tue Sep 7 22:20:26 2010 (r48830)
+++ trunk/tools/dev/nci_thunk_gen.pir Tue Sep 7 22:20:30 2010 (r48831)
@@ -860,7 +860,7 @@
"temp_tmpl": "char *t_%i; STRING *ts_%i",
"fill_params_tmpl": ", &ts_%i",
"preamble_tmpl": "t_%i = STRING_IS_NULL(ts_%i) ? (char *)NULL : Parrot_str_to_cstring(interp, ts_%i);",
- "postamble_tmpl": "if (t_%i) Parrot_str_free_cstring(t_%i);" },
+ "postamble_tmpl": "if (!STRING_IS_NULL(ts_%i)) Parrot_str_free_cstring(t_%i);" },
"v": { "as_proto": "void",
"return_type": "void *",
"sig_char": "v",
@@ -889,7 +889,7 @@
"temp_tmpl": "char *t_%i; STRING *ts_%i",
"preamble_tmpl": "t_%i = STRING_IS_NULL(ts_%i) ? (char *) NULL : Parrot_str_to_cstring(interp, ts_%i);",
"call_param_tmpl": "&t_%i",
- "postamble_tmpl": "if (t_%i) Parrot_str_free_cstring(t_%i);" },
+ "postamble_tmpl": "if (!STRING_IS_NULL(ts_%i)) Parrot_str_free_cstring(t_%i);" },
"2": { "as_proto": "short *",
"sig_char": "P",
"return_type": "short",
More information about the parrot-commits
mailing list