Permalink
Browse files

Replace owl_strdup with g_strdup.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Karl Ramm <kcr@mit.edu>
  • Loading branch information...
1 parent ddbbcff commit d4927a70549407fe7f56b4ae1d3949663a370205 @andersk andersk committed Aug 27, 2009
Showing with 145 additions and 152 deletions.
  1. +7 −7 aim.c
  2. +1 −1 buddy.c
  3. +8 −8 cmd.c
  4. +7 −7 commands.c
  5. +1 −1 context.c
  6. +2 −2 dict.c
  7. +1 −1 errqueue.c
  8. +1 −1 filter.c
  9. +3 −3 filterelement.c
  10. +11 −11 functions.c
  11. +6 −6 global.c
  12. +1 −1 history.c
  13. +2 −2 keybinding.c
  14. +2 −2 keymap.c
  15. +4 −4 logging.c
  16. +5 −5 message.c
  17. +1 −1 msgwin.c
  18. +3 −3 owl.c
  19. +9 −9 perlconfig.c
  20. +1 −1 regex.c
  21. +1 −1 select.c
  22. +1 −1 style.c
  23. +2 −2 text.c
  24. +10 −17 util.c
  25. +11 −11 variable.c
  26. +1 −1 view.c
  27. +33 −33 zephyr.c
  28. +10 −10 zwrite.c
View
14 aim.c
@@ -135,9 +135,9 @@ int owl_aim_login(const char *screenname, const char *password)
/* this will leak, I know and just don't care right now */
priv=g_new0(struct owlfaim_priv, 1);
- priv->screenname = owl_strdup(screenname);
- priv->password = owl_strdup(password);
- priv->server = owl_strdup(FAIM_LOGIN_SERVER);
+ priv->screenname = g_strdup(screenname);
+ priv->password = g_strdup(password);
+ priv->server = g_strdup(FAIM_LOGIN_SERVER);
sess->aux_data = priv;
conn=aim_newconn(sess, AIM_CONN_TYPE_AUTH, priv->server ? priv->server : FAIM_LOGIN_SERVER);
@@ -345,7 +345,7 @@ int owl_aim_set_awaymsg(const char *msg)
char *foo;
/* there is a max away message lentgh we should check against */
- foo=owl_strdup(msg);
+ foo=g_strdup(msg);
len=strlen(foo);
if (len>500) {
foo[500]='\0';
@@ -1024,19 +1024,19 @@ static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *con
char *realmsg = NULL;
if (!args->msg) {
- realmsg = owl_strdup("");
+ realmsg = g_strdup("");
} else if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
realmsg = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE",
NULL, NULL, NULL);
} else if(args->icbmflags & AIM_IMFLAGS_ISO_8859_1) {
realmsg = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1",
NULL, NULL, NULL);
} else {
- realmsg = owl_strdup(args->msg);
+ realmsg = g_strdup(args->msg);
}
if (!realmsg) {
- realmsg = owl_strdup("[Error decoding incoming IM]");
+ realmsg = g_strdup("[Error decoding incoming IM]");
}
owl_function_debugmsg("faimtest_parse_incoming_im_chan1: message from: %s", userinfo->sn?userinfo->sn:"");
View
@@ -3,7 +3,7 @@
void owl_buddy_create(owl_buddy *b, int proto, const char *name)
{
b->proto=proto;
- b->name=owl_strdup(name);
+ b->name=g_strdup(name);
b->idlesince=0;
}
View
16 cmd.c
@@ -87,7 +87,7 @@ char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const c
char *tmpbuff;
char *retval = NULL;
- tmpbuff=owl_strdup(cmdbuff);
+ tmpbuff=g_strdup(cmdbuff);
argv=owl_parseline(tmpbuff, &argc);
if (argc < 0) {
g_free(tmpbuff);
@@ -134,18 +134,18 @@ char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, co
int owl_cmd_create_from_template(owl_cmd *cmd, const owl_cmd *templ) {
*cmd = *templ;
if (!templ->name) return(-1);
- cmd->name = owl_strdup(templ->name);
- if (templ->summary) cmd->summary = owl_strdup(templ->summary);
- if (templ->usage) cmd->usage = owl_strdup(templ->usage);
- if (templ->description) cmd->description = owl_strdup(templ->description);
- if (templ->cmd_aliased_to) cmd->cmd_aliased_to = owl_strdup(templ->cmd_aliased_to);
+ cmd->name = g_strdup(templ->name);
+ if (templ->summary) cmd->summary = g_strdup(templ->summary);
+ if (templ->usage) cmd->usage = g_strdup(templ->usage);
+ if (templ->description) cmd->description = g_strdup(templ->description);
+ if (templ->cmd_aliased_to) cmd->cmd_aliased_to = g_strdup(templ->cmd_aliased_to);
return(0);
}
int owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {
memset(cmd, 0, sizeof(owl_cmd));
- cmd->name = owl_strdup(name);
- cmd->cmd_aliased_to = owl_strdup(aliased_to);
+ cmd->name = g_strdup(name);
+ cmd->cmd_aliased_to = g_strdup(aliased_to);
cmd->summary = owl_sprintf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
return(0);
}
View
@@ -1273,7 +1273,7 @@ char *owl_command_next(int argc, const char *const *argv, const char *buff)
last_if_none=1;
argc-=1; argv+=1;
} else if (argc>=2 && !strcmp(argv[1], "--filter")) {
- filter = owl_strdup(argv[2]);
+ filter = g_strdup(argv[2]);
argc-=2; argv+=2;
} else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
filter = owl_function_smartfilter(0, 0);
@@ -1303,7 +1303,7 @@ char *owl_command_prev(int argc, const char *const *argv, const char *buff)
first_if_none=1;
argc-=1; argv+=1;
} else if (argc>=2 && !strcmp(argv[1], "--filter")) {
- filter = owl_strdup(argv[2]);
+ filter = g_strdup(argv[2]);
argc-=2; argv+=2;
} else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
filter = owl_function_smartfilter(0, 0);
@@ -1674,7 +1674,7 @@ char *owl_command_multi(int argc, const char *const *argv, const char *buff)
owl_function_makemsg("Invalid arguments to 'multi' command.");
return NULL;
}
- newbuff = owl_strdup(skiptokens(buff, 1));
+ newbuff = g_strdup(skiptokens(buff, 1));
if (!strcmp(argv[0], "(")) {
for (i=strlen(newbuff)-1; i>=0; i--) {
if (newbuff[i] == ')') {
@@ -2500,7 +2500,7 @@ char *owl_command_getview(int argc, const char *const *argv, const char *buff)
return NULL;
}
filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
- if (filtname) return owl_strdup(filtname);
+ if (filtname) return g_strdup(filtname);
return NULL;
}
@@ -2515,7 +2515,7 @@ char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
argv[1], tmpbuff, 1024)) {
return NULL;
}
- return owl_strdup(tmpbuff);
+ return g_strdup(tmpbuff);
}
char *owl_command_getfilter(int argc, const char *const *argv, const char *buf)
@@ -2575,7 +2575,7 @@ char *owl_command_aimlogin(int argc, const char *const *argv, const char *buff)
/* if we get two arguments, ask for the password */
if (argc==2) {
owl_editwin *e = owl_function_start_password("AIM Password: ");
- owl_editwin_set_cbdata(e, owl_strdup(argv[1]), g_free);
+ owl_editwin_set_cbdata(e, g_strdup(argv[1]), g_free);
owl_editwin_set_callback(e, owl_callback_aimlogin);
return(NULL);
} else {
@@ -2603,7 +2603,7 @@ char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
return NULL;
}
stylename = owl_view_get_style_name(owl_global_get_current_view(&g));
- if (stylename) return owl_strdup(stylename);
+ if (stylename) return g_strdup(stylename);
return NULL;
}
View
@@ -14,7 +14,7 @@ owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_windo
c->mode = mode;
c->data = data;
c->cursor = cursor ? g_object_ref(cursor) : NULL;
- c->keymap = owl_strdup(keymap);
+ c->keymap = g_strdup(keymap);
return c;
}
View
4 dict.c
@@ -64,7 +64,7 @@ int owl_dict_get_keys(const owl_dict *d, owl_list *l) {
char *dupk;
if (owl_list_create(l)) return(-1);
for (i=0; i<d->size; i++) {
- if ((dupk = owl_strdup(d->els[i].k)) == NULL) return(-1);
+ if ((dupk = g_strdup(d->els[i].k)) == NULL) return(-1);
owl_list_append_element(l, dupk);
}
return(0);
@@ -99,7 +99,7 @@ int owl_dict_insert_element(owl_dict *d, const char *k, void *v, void (*delete_o
d->avail = avail;
if (d->els==NULL) return(-1);
}
- if ((dupk = owl_strdup(k)) == NULL) return(-1);
+ if ((dupk = g_strdup(k)) == NULL) return(-1);
if (pos!=d->size) {
/* shift forward to leave us a slot */
memmove(d->els+pos+1, d->els+pos,
View
@@ -7,7 +7,7 @@ void owl_errqueue_init(owl_errqueue *eq)
void owl_errqueue_append_err(owl_errqueue *eq, const char *msg)
{
- owl_list_append_element(&(eq->errlist), owl_strdup(msg));
+ owl_list_append_element(&(eq->errlist), g_strdup(msg));
}
/* fmtext should already be initialized */
View
@@ -20,7 +20,7 @@ owl_filter *owl_filter_new(const char *name, int argc, const char *const *argv)
f = g_new(owl_filter, 1);
- f->name=owl_strdup(name);
+ f->name=g_strdup(name);
f->fgcolor=OWL_COLOR_DEFAULT;
f->bgcolor=OWL_COLOR_DEFAULT;
View
@@ -213,7 +213,7 @@ void owl_filterelement_create_false(owl_filterelement *fe)
int owl_filterelement_create_re(owl_filterelement *fe, const char *field, const char *re)
{
owl_filterelement_create(fe);
- fe->field=owl_strdup(field);
+ fe->field=g_strdup(field);
if(owl_regex_create(&(fe->re), re)) {
g_free(fe->field);
fe->field = NULL;
@@ -227,15 +227,15 @@ int owl_filterelement_create_re(owl_filterelement *fe, const char *field, const
void owl_filterelement_create_filter(owl_filterelement *fe, const char *name)
{
owl_filterelement_create(fe);
- fe->field=owl_strdup(name);
+ fe->field=g_strdup(name);
fe->match_message = owl_filterelement_match_filter;
fe->print_elt = owl_filterelement_print_filter;
}
void owl_filterelement_create_perl(owl_filterelement *fe, const char *name)
{
owl_filterelement_create(fe);
- fe->field=owl_strdup(name);
+ fe->field=g_strdup(name);
fe->match_message = owl_filterelement_match_perl;
fe->print_elt = owl_filterelement_print_perl;
}
View
@@ -357,7 +357,7 @@ void owl_function_aimwrite_setup(const char *to)
owl_function_write_setup("message");
owl_function_start_edit_win(line,
&owl_callback_aimwrite,
- owl_strdup(to),
+ g_strdup(to),
g_free);
g_free(line);
}
@@ -435,7 +435,7 @@ void owl_function_zcrypt(owl_zwrite *z, const char *msg)
if (msg) {
owl_zwrite_set_message(z, msg);
}
- old_msg = owl_strdup(owl_zwrite_get_message(z));
+ old_msg = g_strdup(owl_zwrite_get_message(z));
zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir());
argv[0] = "zcrypt";
@@ -490,7 +490,7 @@ void owl_function_aimwrite(const char *to, const char *msg, bool unwrap)
owl_message *m;
/* make a formatted copy of the message */
- format_msg = owl_strdup(msg);
+ format_msg = g_strdup(msg);
if (unwrap)
owl_text_wordunwrap(format_msg);
@@ -521,7 +521,7 @@ void owl_function_send_aimawymsg(const char *to, const char *msg)
owl_message *m;
/* make a formatted copy of the message */
- format_msg=owl_strdup(msg);
+ format_msg=g_strdup(msg);
owl_text_wordunwrap(format_msg);
/* send the message */
@@ -2190,7 +2190,7 @@ char *owl_function_create_negative_filter(const char *filtername)
owl_function_debugmsg("owl_function_create_negative_filter");
if (!strncmp(filtername, "not-", 4)) {
- newname=owl_strdup(filtername+4);
+ newname=g_strdup(filtername+4);
} else {
newname=owl_sprintf("not-%s", filtername);
}
@@ -2296,9 +2296,9 @@ char *owl_function_classinstfilt(const char *c, const char *i, int related)
instance = owl_util_baseclass(i);
}
} else {
- class = owl_strdup(c);
+ class = g_strdup(c);
if (i) {
- instance = owl_strdup(i);
+ instance = g_strdup(i);
}
}
@@ -2428,7 +2428,7 @@ char *owl_function_aimuserfilt(const char *user)
/* if it already exists then go with it. This lets users override */
if (owl_global_get_filter(&g, filtname)) {
- return(owl_strdup(filtname));
+ return(g_strdup(filtname));
}
/* create the new-internal filter */
@@ -3050,7 +3050,7 @@ void owl_function_buddylist(int aim, int zephyr, const char *filename)
if (idle!=0) {
timestr=owl_util_minutes_to_timestr(idle);
} else {
- timestr=owl_strdup("");
+ timestr=g_strdup("");
}
owl_fmtext_appendf_normal(&fm, " %-20.20s %-12.12s\n", owl_buddy_get_name(b), timestr);
g_free(timestr);
@@ -3285,7 +3285,7 @@ void owl_function_source(const char *filename)
if (!filename) {
fail_silent = 1;
- path = owl_strdup(owl_global_get_startupfile(&g));
+ path = g_strdup(owl_global_get_startupfile(&g));
} else {
path = owl_util_makepath(filename);
}
@@ -3388,7 +3388,7 @@ void owl_function_log_err(const char *string)
char *buff;
now=time(NULL);
- date=owl_strdup(ctime(&now));
+ date=g_strdup(ctime(&now));
date[strlen(date)-1]='\0';
buff = owl_sprintf("%s %s", date, string);
View
@@ -25,9 +25,9 @@ void owl_global_init(owl_global *g) {
gethostname(hostname, MAXHOSTNAMELEN);
hent=gethostbyname(hostname);
if (!hent) {
- g->thishost=owl_strdup("localhost");
+ g->thishost=g_strdup("localhost");
} else {
- g->thishost=owl_strdup(hent->h_name);
+ g->thishost=g_strdup(hent->h_name);
}
g->lines=LINES;
@@ -89,7 +89,7 @@ void owl_global_init(owl_global *g) {
homedir = getenv("HOME");
if (!homedir)
homedir = g_get_home_dir();
- g->homedir = owl_strdup(homedir);
+ g->homedir = g_strdup(homedir);
g->confdir = NULL;
g->startupfile = NULL;
@@ -379,7 +379,7 @@ const char *owl_global_get_confdir(const owl_global *g) {
*/
void owl_global_set_confdir(owl_global *g, const char *cd) {
g_free(g->confdir);
- g->confdir = owl_strdup(cd);
+ g->confdir = g_strdup(cd);
g_free(g->startupfile);
g->startupfile = owl_sprintf("%s/startup", cd);
}
@@ -700,7 +700,7 @@ void owl_global_set_aimloggedin(owl_global *g, const char *screenname)
g->aim_loggedin=1;
if (g->aim_screenname) g_free(g->aim_screenname);
if (g->aim_screenname_for_filters) g_free(g->aim_screenname_for_filters);
- g->aim_screenname=owl_strdup(screenname);
+ g->aim_screenname=g_strdup(screenname);
sn_escaped = owl_text_quote(screenname, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
g->aim_screenname_for_filters = owl_arg_quote(sn_escaped);
g_free(sn_escaped);
@@ -972,7 +972,7 @@ FILE *owl_global_get_debug_file_handle(owl_global *g) {
g->debug_file = fdopen(fd, "a");
g_free(open_file);
- open_file = owl_strdup(filename);
+ open_file = g_strdup(filename);
}
return g->debug_file;
}
View
@@ -68,7 +68,7 @@ void owl_history_store(owl_history *h, const char *line)
}
/* add the new line */
- owl_list_prepend_element(&(h->hist), owl_strdup(line));
+ owl_list_prepend_element(&(h->hist), g_strdup(line));
}
void owl_history_set_partial(owl_history *h)
View
@@ -26,9 +26,9 @@ int owl_keybinding_init(owl_keybinding *kb, const char *keyseq, const char *comm
return(-1);
}
- if (command) kb->command = owl_strdup(command);
+ if (command) kb->command = g_strdup(command);
kb->function_fn = function_fn;
- if (desc) kb->desc = owl_strdup(desc);
+ if (desc) kb->desc = g_strdup(desc);
else kb->desc = NULL;
return(0);
}
View
@@ -8,8 +8,8 @@ static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm
int owl_keymap_init(owl_keymap *km, const char *name, const char *desc, void (*default_fn)(owl_input), void (*prealways_fn)(owl_input), void (*postalways_fn)(owl_input))
{
if (!name || !desc) return(-1);
- if ((km->name = owl_strdup(name)) == NULL) return(-1);
- if ((km->desc = owl_strdup(desc)) == NULL) return(-1);
+ if ((km->name = g_strdup(name)) == NULL) return(-1);
+ if ((km->desc = g_strdup(desc)) == NULL) return(-1);
if (0 != owl_list_create(&km->bindings)) return(-1);
km->parent = NULL;
km->default_fn = default_fn;
Oops, something went wrong.

0 comments on commit d4927a7

Please sign in to comment.