sps.c
State addCommand(Program *prog, const Command *cmd) {
    prog->len++;

    Command *p = realloc(prog->cmds, sizeof(Command) * prog->len);
    if (p == NULL)
        return ERR_MEMORY;
    prog->cmds = p;

    size_t last = prog->len - 1;
    // the name is not needed for running, copied just for debugging purposes
    strcpy(prog->cmds[last].name, cmd->name);
    prog->cmds[last].fn = cmd->fn;
    // not set yet
    prog->cmds[last].argStr = NULL;
    return SUCCESS;
}
// appends a command to the program structure
appends a command to the program structure
appends a command to the program structure
State addCommand(Program *prog, const Command *cmd) {
    prog->len++;
    Command *p = realloc(prog->cmds, sizeof(Command) * prog->len);
    if (p == NULL)
        return ERR_MEMORY;
    prog->cmds = p;
    size_t last = prog->len - 1;
    strcpy(prog->cmds[last].name, cmd->name);
    prog->cmds[last].fn = cmd->fn;
    prog->cmds[last].argStr = NULL;
    return SUCCESS;
}
State addCommand ( Program * prog , const Command * cmd ) { prog -> len ++ ; Command * p = realloc ( prog -> cmds , sizeof ( Command ) * prog -> len ) ; if ( p == NULL ) return ERR_MEMORY ; prog -> cmds = p ; size_t last = prog -> len - 1 ; strcpy ( prog -> cmds [ last ] . name , cmd -> name ) ; prog -> cmds [ last ] . fn = cmd -> fn ; prog -> cmds [ last ] . argStr = NULL ; return SUCCESS ; }
appends a command to the program structure
appends a command to the program structure
// the name is not needed for running, copied just for debugging purposes // not set yet