Index: config/gen/platform/generic/exec.c =================================================================== --- config/gen/platform/generic/exec.c (版本 42982) +++ config/gen/platform/generic/exec.c (工作副本) @@ -54,11 +54,11 @@ } else { /* child */ - char *cmd = Parrot_str_to_cstring(interp, command); - int status = execlp("sh", "sh", "-c", cmd, (void *)NULL); + char * const cmd = Parrot_str_to_cstring(interp, command); + int status = execlp("sh", "sh", "-c", cmd, (void *)NULL); /* if we get here, something's horribly wrong, but free anyway... */ - mem_sys_free(cmd); + Parrot_str_free_cstring(cmd); if (status) exit(status); @@ -96,8 +96,7 @@ if (child) { /* parent */ int status; - pid_t returnstat; - returnstat = waitpid(child, &status, 0); + pid_t returnstat = waitpid(child, &status, 0); UNUSED(returnstat); return status; } @@ -105,19 +104,18 @@ /* child. Be horribly profligate with memory, since we're about to be something else */ int status, i; - char **argv; STRING *s; - char *cmd; + char *cmd; + char **argv = (char **)mem_sys_allocate((len+1)*sizeof (char *)); - argv = (char **)mem_sys_allocate((len+1)*sizeof (char *)); for (i = 0; i < len; ++i) { s = VTABLE_get_string_keyed_int(interp, cmdargs, i); argv[i] = Parrot_str_to_cstring(interp, s); } - cmd = argv[0]; - argv[i] = NULL; - status = execvp(cmd, argv); + cmd = argv[0]; + argv[i] = NULL; + status = execvp(cmd, argv); /* if we get here, something's horribly wrong... */ if (status) { exit(status); Index: src/debug.c =================================================================== --- src/debug.c (版本 42982) +++ src/debug.c (工作副本) @@ -1274,7 +1274,7 @@ tmp_stdin, readline, "S->S", prompt, & s); { - char * aux = Parrot_str_to_cstring(interpdeb, s); + char * const aux = Parrot_str_to_cstring(interpdeb, s); strcpy(c, aux); Parrot_str_free_cstring(aux); } Index: src/dynext.c =================================================================== --- src/dynext.c (版本 42982) +++ src/dynext.c (工作副本) @@ -233,8 +233,8 @@ { ASSERT_ARGS(dlopen_string) - char *pathstr = Parrot_str_to_cstring(interp, path); - void *handle = Parrot_dlopen(pathstr); + char * const pathstr = Parrot_str_to_cstring(interp, path); + void * handle = Parrot_dlopen(pathstr); Parrot_str_free_cstring(pathstr); return handle; } Index: src/interp/inter_misc.c =================================================================== --- src/interp/inter_misc.c (版本 42982) +++ src/interp/inter_misc.c (工作副本) @@ -341,9 +341,9 @@ else { /* Need to strip back to what follows the final / or \. */ - STRING *fullname = VTABLE_get_string(interp, exe_name); - char *fullname_c = Parrot_str_to_cstring(interp, fullname); - int pos = strlen(fullname_c) - 1; + STRING * fullname = VTABLE_get_string(interp, exe_name); + char * const fullname_c = Parrot_str_to_cstring(interp, fullname); + int pos = strlen(fullname_c) - 1; while (pos > 0 && fullname_c[pos] != '/' @@ -354,7 +354,7 @@ pos++; basename = Parrot_str_new(interp, fullname_c + pos, 0); - mem_sys_free(fullname_c); + Parrot_str_free_cstring(fullname_c); return basename; } Index: src/io/unix.c =================================================================== --- src/io/unix.c (版本 42982) +++ src/io/unix.c (工作副本) @@ -764,7 +764,7 @@ } # else - UNUSED(l); + UNUSED(filehandle); UNUSED(command); UNUSED(flags); Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, Index: src/pmc/os.pmc =================================================================== --- src/pmc/os.pmc (版本 42982) +++ src/pmc/os.pmc (工作副本) @@ -476,11 +476,11 @@ */ METHOD readdir(STRING *path) { #ifndef _MSC_VER + char * const cpath = Parrot_str_to_cstring(interp, path); + DIR *dir = opendir(cpath); struct dirent *dirent; PMC *array; - char *cpath = Parrot_str_to_cstring(interp, path); STRING *retval; - DIR *dir = opendir(cpath); Parrot_str_free_cstring(cpath); Index: src/pmc/string.pmc =================================================================== --- src/pmc/string.pmc (版本 42982) +++ src/pmc/string.pmc (工作副本) @@ -52,6 +52,10 @@ VTABLE void mark() { STRING *str_val; + + if (!PMC_data(SELF)) + return; + GET_ATTR_str_val(INTERP, SELF, str_val); Parrot_gc_mark_STRING_alive(INTERP, str_val); } @@ -202,8 +206,8 @@ /* Only allow constant PMCs to embed constant strings */ if (PObj_constant_TEST(SELF) && !PObj_constant_TEST(value)) { - char *copy = Parrot_str_to_cstring(INTERP, value); - value = Parrot_str_new_init(INTERP, copy, strlen(copy), + char * const copy = Parrot_str_to_cstring(INTERP, value); + value = Parrot_str_new_init(INTERP, copy, strlen(copy), PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET, PObj_constant_FLAG); Parrot_str_free_cstring(copy);