Changeset 36486be


Ignore:
Timestamp:
Aug 22, 2009, 12:50:08 AM (15 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, 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>
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    r2646676 r36486be  
    943943 
    944944  if (modname) {
    945     if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
    946       /* perror("memrequest: malloc"); */
    947       return -1;
    948     }
    949     sprintf(filename, "%s/%s.ocm", priv->aimbinarypath, modname);
     945    filename = owl_sprintf("%s/%s.ocm", priv->aimbinarypath, modname);
    950946  } else {
    951     if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
    952       /* perror("memrequest: malloc"); */
    953       return -1;
    954     }
    955     sprintf(filename, "%s/%s", priv->aimbinarypath, defaultmod);
     947    filename = owl_sprintf("%s/%s", priv->aimbinarypath, defaultmod);
    956948  }
    957949 
  • 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
  • functions.c

    r303a9e1 r36486be  
    20302030
    20312031  buff = skiptokens(buff, 1);
    2032   newbuff = owl_malloc(strlen(buff)+strlen(redirect)+1);
    2033   strcpy(newbuff, buff);
    2034   strcat(newbuff, redirect);
     2032  newbuff = owl_sprintf("%s%s", buff, redirect);
    20352033
    20362034  if (type == 1) {
  • keymap.c

    r12bc46a r36486be  
    5656char *owl_keymap_summary(const owl_keymap *km)
    5757{
    58   char *s;
    59   int slen;
    6058  if (!km || !km->name || !km->desc) return NULL;
    61   slen = strlen(km->name)+strlen(km->desc)+20;
    62   s = owl_malloc(slen);
    63   snprintf(s, slen-1, "%-15s - %s", km->name, km->desc);
    64   return s;
     59  return owl_sprintf("%-15s - %s", km->name, km->desc);
    6560}
    6661
  • util.c

    r4083c49 r36486be  
    147147    } else {
    148148      args=owl_realloc(args, sizeof(char *) * (count+1));
    149       args[count]=owl_malloc(strlen(foo)+1);
    150       strcpy(args[count], foo);
     149      args[count] = owl_strdup(foo);
    151150      count++;
    152151    }
     
    325324      /* add the argument */
    326325      argv=owl_realloc(argv, sizeof(char *)*((*argc)+1));
    327       argv[*argc]=owl_malloc(strlen(curarg)+2);
    328       strcpy(argv[*argc], curarg);
     326      argv[*argc] = owl_strdup(curarg);
    329327      *argc=*argc+1;
    330328      strcpy(curarg, "");
  • zcrypt.c

    re19eb97 r36486be  
    245245    } else {
    246246      /* Prepare result to be returned */
    247       char *temp = keyfile;
    248       keyfile = owl_malloc(strlen(temp) + 1);
    249       if (keyfile) {
    250         strcpy(keyfile, temp);
    251       } else {
    252         /* printf("Memory allocation error.\n"); */
    253       }
     247      keyfile = owl_strdup(keyfile);
    254248    }
    255249   
  • zephyr.c

    r4083c49 r36486be  
    988988char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
    989989{
    990   char *out;
    991 
    992   out=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+30);
    993   sprintf(out, "%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
    994   return(out);
     990  return owl_sprintf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
    995991}
    996992
  • zwrite.c

    r4083c49 r36486be  
    170170     
    171171      /* simple hack for now to nuke stderr */
    172       openline=owl_malloc(strlen(zsigproc)+40);
    173       strcpy(openline, zsigproc);
    174 #if !(OWL_STDERR_REDIR)
    175       strcat(openline, " 2> /dev/null");
     172#if OWL_STDERR_REDIR
     173      openline = owl_strdup(zsigproc);
     174#else
     175      openline = owl_sprintf("%s 2> /dev/null", zsigproc);
    176176#endif
    177177      file=popen(openline, "r");
Note: See TracChangeset for help on using the changeset viewer.