Changeset 36486be for cmd.c


Ignore:
Timestamp:
Aug 22, 2009, 12:50:08 AM (12 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
24ccc01
Parents:
303a9e1
git-author:
Anders Kaseorg <andersk@mit.edu> (08/22/09 00:47:21)
git-committer:
Anders Kaseorg <andersk@mit.edu> (08/22/09 00:50:08)
Message:
Replace several owl_malloc, sprintf sequences with owl_strdup or owl_sprintf.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cmd.c

    r0a0fb74 r36486be  
    147147  cmd->name = owl_strdup(name);
    148148  cmd->cmd_aliased_to = owl_strdup(aliased_to);
    149   cmd->summary = owl_malloc(strlen(aliased_to)+strlen(OWL_CMD_ALIAS_SUMMARY_PREFIX)+2);
    150   strcpy(cmd->summary, OWL_CMD_ALIAS_SUMMARY_PREFIX);
    151   strcat(cmd->summary, aliased_to);
     149  cmd->summary = owl_sprintf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
    152150  return(0);
    153151}
     
    181179    } else {
    182180      cmdbuffargs = skiptokens(cmdbuff, 1);
    183       newcmd = owl_malloc(strlen(cmd->cmd_aliased_to)+strlen(cmdbuffargs)+2);
    184       strcpy(newcmd, cmd->cmd_aliased_to);
    185       strcat(newcmd, " ");
    186       strcat(newcmd, cmdbuffargs);
     181      newcmd = owl_sprintf("%s %s", cmd->cmd_aliased_to, cmdbuffargs);
    187182      rv = owl_function_command(newcmd);
    188183      owl_free(newcmd);
     
    244239/* returns a summary line describing this keymap.  the caller must free. */
    245240char *owl_cmd_describe(const owl_cmd *cmd) {
    246   char *s;
    247   int slen;
    248241  if (!cmd || !cmd->name || !cmd->summary) return NULL;
    249   slen = strlen(cmd->name)+strlen(cmd->summary)+30;
    250   s = owl_malloc(slen);
    251   snprintf(s, slen-1, "%-25s - %s", cmd->name, cmd->summary);
    252   return s;
     242  return owl_sprintf("%-25s - %s", cmd->name, cmd->summary);
    253243}
    254244
Note: See TracChangeset for help on using the changeset viewer.