diff options
author | Kipling Inscore <k@bijna.net> | 2010-03-30 20:47:25 -0700 |
---|---|---|
committer | Shawn Betts <sabetts@Woaaahdudelike.local> | 2010-03-31 09:00:51 -0700 |
commit | 526b74d89dfad6772d15004228ff617898918daf (patch) | |
tree | 78a68fabe44b4bab6166157137db7ec06f3415d0 /src | |
parent | 24c831b03816bd9821198cc9d24f0cf9e1e7e062 (diff) | |
download | ratpoison-526b74d89dfad6772d15004228ff617898918daf.zip |
Cleaned up some cmdret, sbuf, char * usage; eliminating associated memory leaks
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/actions.c b/src/actions.c index 052b099..2b34a5f 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1041,7 +1041,12 @@ cmdret * cmd_unmanage (int interactive, struct cmdarg **args) { if (args[0] == NULL && !interactive) - return cmdret_new (RET_SUCCESS, "%s", list_unmanaged_windows()); + { + char *s = list_unmanaged_windows(); + cmdret *ret = cmdret_new (RET_SUCCESS, "%s", s); + free (s); + return ret; + } if (args[0]) add_unmanaged_window(ARG_STRING(0)); @@ -1522,7 +1527,11 @@ read_keymap (struct argspec *spec, struct sbuf *s, struct cmdarg **arg) rp_keymap *map; map = find_keymap (input); if (map == NULL) - return cmdret_new (RET_FAILURE, "unknown keymap '%s'", input); + { + cmdret *ret = cmdret_new (RET_FAILURE, "unknown keymap '%s'", input); + free (input); + return ret; + } *arg = xmalloc (sizeof(struct cmdarg)); (*arg)->type = spec->type; (*arg)->arg.keymap = map; @@ -1693,6 +1702,8 @@ exec_completions (char *str) } } + sbuf_free (line); + free (partial); pclose (file); @@ -3468,8 +3479,8 @@ cmd_help (int interactive, struct cmdarg **args) { struct sbuf *help_list; char *keysym_name; - char *tmp; int i; + cmdret *ret; help_list = sbuf_new (0); @@ -3484,10 +3495,9 @@ cmd_help (int interactive, struct cmdarg **args) sbuf_concat (help_list, "\n"); } - tmp = sbuf_get (help_list); - free (help_list); - - return cmdret_new (RET_SUCCESS, "%s", tmp); + ret = cmdret_new (RET_SUCCESS, "%s", sbuf_get (help_list)); + sbuf_free (help_list); + return ret; } return cmdret_new (RET_SUCCESS, NULL); @@ -4186,7 +4196,6 @@ cmd_unsetenv (int interactive UNUSED, struct cmdarg **args) s = sbuf_new(0); sbuf_copy (s, ARG_STRING(0)); sbuf_concat (s, "="); -/* str = sbuf_free_struct (s); */ putenv (sbuf_get(s)); sbuf_free (s); return cmdret_new (RET_SUCCESS, NULL); @@ -4198,7 +4207,6 @@ cmdret * cmd_info (int interactive UNUSED, struct cmdarg **args) { struct sbuf *buf; - char *tmp; if (current_window() != NULL) { rp_window *win = current_window(); @@ -4210,6 +4218,7 @@ cmd_info (int interactive UNUSED, struct cmdarg **args) if (win_elem) { char *s; + cmdret *ret; if (args[0] == NULL) s = defaults.info_fmt; @@ -4217,8 +4226,9 @@ cmd_info (int interactive UNUSED, struct cmdarg **args) s = ARG_STRING(0); buf = sbuf_new (0); format_string (s, win_elem, buf); - tmp = sbuf_free_struct (buf); - return cmdret_new (RET_SUCCESS, "%s", tmp); + ret = cmdret_new (RET_SUCCESS, "%s", sbuf_get (buf)); + sbuf_free (buf); + return ret; } } @@ -4831,8 +4841,7 @@ fdump (rp_screen *screen) free (t); } - tmp = sbuf_get (s); - free (s); + tmp = sbuf_free_struct (s); return tmp; } |