Changeset 117c21c


Ignore:
Timestamp:
Jun 19, 2011, 1:49:34 AM (6 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
9e86f6f
Parents:
aad166a
git-author:
Anders Kaseorg <andersk@mit.edu> (06/18/11 20:41:46)
git-committer:
Anders Kaseorg <andersk@mit.edu> (06/19/11 01:49:34)
Message:
commands_to_init: Copy string literals

This squashes a bunch of -Wwrite-strings warnings from temporarily
storing string literals in char * fields.

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

Legend:

Unmodified
Added
Removed
  • commands.c

    raad166a r117c21c  
    88/* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */
    99#define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \
    10         { name, summary, usage, description, ctx, \
     10        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    1111          NULL, fn, NULL, NULL, NULL, NULL, NULL, NULL }
    1212
    1313/* fn is "void foo(void)" */
    1414#define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \
    15         { name, summary, usage, description, ctx, \
     15        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    1616          NULL, NULL, fn, NULL, NULL, NULL, NULL, NULL }
    1717
    1818/* fn is "void foo(int)" */
    1919#define OWLCMD_INT(name, fn, ctx, summary, usage, description) \
    20         { name, summary, usage, description, ctx, \
     20        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    2121          NULL, NULL, NULL, fn, NULL, NULL, NULL, NULL }
    2222
    2323#define OWLCMD_ALIAS(name, actualname) \
    24         { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \
    25           actualname, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
     24        { g_strdup(name), g_strdup(OWL_CMD_ALIAS_SUMMARY_PREFIX actualname), g_strdup(""), g_strdup(""), OWL_CTX_ANY, \
     25          g_strdup(actualname), NULL, NULL, NULL, NULL, NULL, NULL, NULL }
    2626
    2727/* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */
    2828#define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \
    29         { name, summary, usage, description, ctx, \
     29        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    3030          NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL }
    3131
    3232/* fn is "void foo(void)" */
    3333#define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \
    34         { name, summary, usage, description, ctx, \
     34        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    3535          NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL, NULL }
    3636
    3737/* fn is "void foo(int)" */
    3838#define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \
    39         { name, summary, usage, description, ctx, \
     39        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    4040          NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn), NULL }
    4141
     
    10411041  };
    10421042
    1043   return owl_cmddict_add_from_list(cd, commands_to_init);
     1043  int ret = owl_cmddict_add_from_list(cd, commands_to_init);
     1044  owl_cmd *cmd;
     1045  for (cmd = commands_to_init; cmd->name != NULL; cmd++)
     1046    owl_cmd_cleanup(cmd);
     1047  return ret;
    10441048}
    10451049
Note: See TracChangeset for help on using the changeset viewer.