Ticket #886: tt_886.patch

File tt_886.patch, 5.8 KB (added by jimmy, 12 years ago)
  • config/gen/platform/generic/exec.c

     
    5454    } 
    5555    else { 
    5656        /* child */ 
    57         char *cmd    = Parrot_str_to_cstring(interp, command); 
    58         int   status = execlp("sh", "sh", "-c", cmd, (void *)NULL); 
     57        char * const cmd    = Parrot_str_to_cstring(interp, command); 
     58        int          status = execlp("sh", "sh", "-c", cmd, (void *)NULL); 
    5959 
    6060        /* if we get here, something's horribly wrong, but free anyway... */ 
    61         mem_sys_free(cmd); 
     61        Parrot_str_free_cstring(cmd); 
    6262 
    6363        if (status) 
    6464            exit(status); 
     
    9696    if (child) { 
    9797        /* parent */ 
    9898        int status; 
    99         pid_t returnstat; 
    100         returnstat = waitpid(child, &status, 0); 
     99        pid_t returnstat = waitpid(child, &status, 0); 
    101100        UNUSED(returnstat); 
    102101        return status; 
    103102    } 
     
    105104        /* child. Be horribly profligate with memory, since we're 
    106105           about to be something else */ 
    107106        int status, i; 
    108         char **argv; 
    109107        STRING *s; 
    110         char *cmd; 
     108        char   *cmd; 
     109        char  **argv = (char **)mem_sys_allocate((len+1)*sizeof (char *)); 
    111110 
    112         argv = (char **)mem_sys_allocate((len+1)*sizeof (char *)); 
    113111        for (i = 0; i < len; ++i) { 
    114112            s = VTABLE_get_string_keyed_int(interp, cmdargs, i); 
    115113            argv[i] = Parrot_str_to_cstring(interp, s); 
    116114        } 
    117         cmd = argv[0]; 
    118         argv[i] = NULL; 
    119115 
    120         status = execvp(cmd, argv); 
     116        cmd     = argv[0]; 
     117        argv[i] = NULL; 
     118        status  = execvp(cmd, argv); 
    121119        /* if we get here, something's horribly wrong... */ 
    122120        if (status) { 
    123121            exit(status); 
  • src/debug.c

     
    12741274            tmp_stdin, readline, 
    12751275            "S->S", prompt, & s); 
    12761276        { 
    1277         char * aux = Parrot_str_to_cstring(interpdeb, s); 
     1277        char * const aux = Parrot_str_to_cstring(interpdeb, s); 
    12781278        strcpy(c, aux); 
    12791279        Parrot_str_free_cstring(aux); 
    12801280        } 
  • src/dynext.c

     
    233233{ 
    234234    ASSERT_ARGS(dlopen_string) 
    235235 
    236     char *pathstr = Parrot_str_to_cstring(interp, path); 
    237     void *handle = Parrot_dlopen(pathstr); 
     236    char * const pathstr = Parrot_str_to_cstring(interp, path); 
     237    void *       handle = Parrot_dlopen(pathstr); 
    238238    Parrot_str_free_cstring(pathstr); 
    239239    return handle; 
    240240} 
  • src/interp/inter_misc.c

     
    341341 
    342342            else { 
    343343                /* Need to strip back to what follows the final / or \. */ 
    344                 STRING *fullname   = VTABLE_get_string(interp, exe_name); 
    345                 char   *fullname_c = Parrot_str_to_cstring(interp, fullname); 
    346                 int     pos        = strlen(fullname_c) - 1; 
     344                STRING *       fullname   = VTABLE_get_string(interp, exe_name); 
     345                char   * const fullname_c = Parrot_str_to_cstring(interp, fullname); 
     346                int            pos        = strlen(fullname_c) - 1; 
    347347 
    348348                while (pos              >  0 
    349349                &&     fullname_c[pos] != '/' 
     
    354354                    pos++; 
    355355 
    356356                basename = Parrot_str_new(interp, fullname_c + pos, 0); 
    357                 mem_sys_free(fullname_c); 
     357                Parrot_str_free_cstring(fullname_c); 
    358358 
    359359                return basename; 
    360360            } 
  • src/io/unix.c

     
    764764    } 
    765765 
    766766#  else 
    767     UNUSED(l); 
     767    UNUSED(filehandle); 
    768768    UNUSED(command); 
    769769    UNUSED(flags); 
    770770    Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, 
  • src/pmc/os.pmc

     
    476476*/ 
    477477    METHOD readdir(STRING *path) { 
    478478#ifndef _MSC_VER 
     479        char  * const cpath = Parrot_str_to_cstring(interp, path); 
     480        DIR           *dir  = opendir(cpath); 
    479481        struct dirent *dirent; 
    480482        PMC           *array; 
    481         char          *cpath = Parrot_str_to_cstring(interp, path); 
    482483        STRING        *retval; 
    483         DIR           *dir   = opendir(cpath); 
    484484 
    485485        Parrot_str_free_cstring(cpath); 
    486486 
  • src/pmc/string.pmc

     
    5252 
    5353    VTABLE void mark() { 
    5454        STRING *str_val; 
     55 
     56        if (!PMC_data(SELF)) 
     57            return; 
     58 
    5559        GET_ATTR_str_val(INTERP, SELF, str_val); 
    5660        Parrot_gc_mark_STRING_alive(INTERP, str_val); 
    5761    } 
     
    202206 
    203207        /* Only allow constant PMCs to embed constant strings */ 
    204208        if (PObj_constant_TEST(SELF) && !PObj_constant_TEST(value)) { 
    205             char *copy = Parrot_str_to_cstring(INTERP, value); 
    206             value      = Parrot_str_new_init(INTERP, copy, strlen(copy), 
     209            char * const copy = Parrot_str_to_cstring(INTERP, value); 
     210            value             = Parrot_str_new_init(INTERP, copy, strlen(copy), 
    207211                PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET, 
    208212                PObj_constant_FLAG); 
    209213            Parrot_str_free_cstring(copy);