Index: src/pmc/packfile.pmc =================================================================== --- src/pmc/packfile.pmc (revision 45332) +++ src/pmc/packfile.pmc (working copy) @@ -171,12 +171,13 @@ */ VTABLE void set_string_native(STRING *str) { PackFile * const pf = PackFile_new(interp, 0); - opcode_t * const ptr = (opcode_t *)Parrot_string_cstring(interp, str); + opcode_t * const ptr = (opcode_t *)Parrot_str_to_cstring(interp, str); const int length = Parrot_str_byte_length(interp, str); Parrot_Packfile_attributes * const attrs = PARROT_PACKFILE(SELF); if (!PackFile_unpack(interp, pf, ptr, length)) { PackFile_destroy(interp, pf); + Parrot_str_free_cstring(ptr); Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE, "Can't unpack packfile."); } @@ -192,6 +193,7 @@ Parrot_unblock_GC_mark(interp); PackFile_destroy(interp, pf); + Parrot_str_free_cstring(ptr); } @@ -250,9 +252,17 @@ if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "uuid_type"))) return attrs->uuid_type; - Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND, - "Packfile: No such integer key \"%s\"", - Parrot_string_cstring(interp, key)); + const char start_buffer[] = "Packfile: No such integer key \""; + STRING * message = + Parrot_str_new(interp, start_buffer, sizeof (start_buffer)); + STRING * const message_end = Parrot_str_new(interp, "\"", 1); + message = Parrot_str_append(interp, message, key); + message = Parrot_str_append(interp, message, message_end); + + PMC * const except = Parrot_ex_build_exception(interp, NULL, + EXCEPTION_KEY_NOT_FOUND, message); + + Parrot_ex_throw_from_c(interp, except); } /* @@ -274,9 +284,17 @@ if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "uuid"))) return PARROT_PACKFILE(SELF)->uuid; - Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND, - "Packfile: No such string key \"%s\"", - Parrot_string_cstring(interp, key)); + const char start_buffer[] = "Packfile: No such string key \""; + STRING * message = + Parrot_str_new(interp, start_buffer, sizeof (start_buffer)); + STRING * const message_end = Parrot_str_new(interp, "\"", 1); + message = Parrot_str_append(interp, message, key); + message = Parrot_str_append(interp, message, message_end); + + PMC * const except = Parrot_ex_build_exception(interp, NULL, + EXCEPTION_KEY_NOT_FOUND, message); + + Parrot_ex_throw_from_c(interp, except); } @@ -350,9 +368,18 @@ attrs->uuid_type = value; return; } - Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND, - "Packfile: No such integer key \"%s\"", - Parrot_string_cstring(interp, key)); + + const char start_buffer[] = "Packfile: No such integer key \""; + STRING * message = + Parrot_str_new(interp, start_buffer, sizeof (start_buffer)); + STRING * const message_end = Parrot_str_new(interp, "\"", 1); + message = Parrot_str_append(interp, message, key); + message = Parrot_str_append(interp, message, message_end); + + PMC * const except = Parrot_ex_build_exception(interp, NULL, + EXCEPTION_KEY_NOT_FOUND, message); + + Parrot_ex_throw_from_c(interp, except); } @@ -394,9 +421,17 @@ return; } - Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND, - "Packfile: No such string key \"%s\"", - Parrot_string_cstring(interp, key)); + const char start_buffer[] = "Packfile: No such integer key \""; + STRING * message = + Parrot_str_new(interp, start_buffer, sizeof (start_buffer)); + STRING * const message_end = Parrot_str_new(interp, "\"", 1); + message = Parrot_str_append(interp, message, key); + message = Parrot_str_append(interp, message, message_end); + + PMC * const except = Parrot_ex_build_exception(interp, NULL, + EXCEPTION_KEY_NOT_FOUND, message); + + Parrot_ex_throw_from_c(interp, except); } /* Index: src/pmc/packfilefixupentry.pmc =================================================================== --- src/pmc/packfilefixupentry.pmc (revision 45332) +++ src/pmc/packfilefixupentry.pmc (working copy) @@ -100,10 +100,12 @@ PARROT_PACKFILEFIXUPENTRY(SELF); PackFile_FixupEntry * entry = mem_gc_allocate_zeroed_typed(INTERP, PackFile_FixupEntry); - + const char * tempName = Parrot_str_to_cstring(interp, attrs->name); entry->type = attrs->type; - entry->name = strdup(Parrot_string_cstring(interp, attrs->name)); + entry->name = strdup(tempName); entry->offset = attrs->offset; + + Parrot_str_free_cstring(tempName); return entry; }