Changeset 96828e4
- Timestamp:
- Feb 11, 2011, 4:31:33 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 35b6eb9
- Parents:
- 9518a85
- git-author:
- Anders Kaseorg <andersk@mit.edu> (08/27/09 00:51:45)
- git-committer:
- Anders Kaseorg <andersk@mit.edu> (02/11/11 16:31:33)
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
aim.c
rc6adf17 r96828e4 134 134 135 135 /* this will leak, I know and just don't care right now */ 136 priv=owl_malloc(sizeof(struct owlfaim_priv)); 137 memset(priv, 0, sizeof(struct owlfaim_priv)); 136 priv=g_new0(struct owlfaim_priv, 1); 138 137 139 138 priv->screenname = owl_strdup(screenname); … … 435 434 436 435 j=strlen(in); 437 out= owl_malloc(j+30);436 out=g_new(char, j+30); 438 437 k=0; 439 438 for (i=0; i<j; i++) { … … 1046 1045 wrapmsg=owl_text_wordwrap(stripmsg, 70); 1047 1046 nz_screenname=owl_aim_normalize_screenname(userinfo->sn); 1048 m= owl_malloc(sizeof(owl_message));1047 m=g_new(owl_message, 1); 1049 1048 owl_message_create_aim(m, 1050 1049 nz_screenname, -
buddylist.c
r1c4b4ca r96828e4 11 11 { 12 12 owl_buddy *b; 13 b= owl_malloc(sizeof(owl_buddy));13 b=g_new(owl_buddy, 1); 14 14 15 15 owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname); … … 52 52 53 53 /* if not, create the login message */ 54 m= owl_malloc(sizeof(owl_message));54 m=g_new(owl_message, 1); 55 55 owl_message_create_aim(m, 56 56 screenname, … … 71 71 72 72 if (owl_buddylist_is_aim_buddy_loggedin(bl, screenname)) { 73 m= owl_malloc(sizeof(owl_message));73 m=g_new(owl_message, 1); 74 74 owl_message_create_aim(m, 75 75 screenname, -
cmd.c
r4d24650 r96828e4 50 50 int owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) { 51 51 owl_cmd *cmd; 52 cmd = owl_malloc(sizeof(owl_cmd));52 cmd = g_new(owl_cmd, 1); 53 53 owl_cmd_create_alias(cmd, alias_from, alias_to); 54 54 owl_perlconfig_new_command(cmd->name); … … 58 58 59 59 int owl_cmddict_add_cmd(owl_cmddict *cd, const owl_cmd * cmd) { 60 owl_cmd * newcmd = owl_malloc(sizeof(owl_cmd));60 owl_cmd * newcmd = g_new(owl_cmd, 1); 61 61 if(owl_cmd_create_from_template(newcmd, cmd) < 0) { 62 62 owl_free(newcmd); -
commands.c
rfba2a65 r96828e4 1328 1328 char opt; 1329 1329 int instance = 0, related = 0, i; 1330 const char **tmp_argv = owl_malloc(sizeof(char *) *argc);1330 const char **tmp_argv = g_new(const char *, argc); 1331 1331 1332 1332 static const struct option options[] = { -
context.c
rcb81570 r96828e4 11 11 if (!(mode & OWL_CTX_MODE_BITS)) 12 12 mode |= OWL_CTX_INTERACTIVE; 13 c = owl_malloc(sizeof *c); 14 memset(c, 0, sizeof(*c)); 13 c = g_new0(owl_context, 1); 15 14 c->mode = mode; 16 15 c->data = data; -
dict.c
rd537350 r96828e4 17 17 int owl_dict_create(owl_dict *d) { 18 18 d->size=0; 19 d->els= owl_malloc(INITSIZE*sizeof(owl_dict_el));19 d->els=g_new(owl_dict_el, INITSIZE); 20 20 d->avail=INITSIZE; 21 21 if (d->els==NULL) return(-1); -
editwin.c
r5f8ec6b r96828e4 72 72 static owl_editwin *owl_editwin_allocate(void) 73 73 { 74 owl_editwin *e; 75 e = owl_malloc(sizeof(owl_editwin)); 76 memset(e, 0, sizeof(*e)); 74 owl_editwin *e = g_new0(owl_editwin, 1); 77 75 e->refcount = 1; 78 76 return e; … … 123 121 owl_history *hist) 124 122 { 125 e->buff= owl_malloc(INCR);123 e->buff=g_new(char, INCR); 126 124 e->buff[0]='\0'; 127 125 e->bufflen=0; … … 303 301 304 302 if (lock > 0) { 305 locktext = owl_malloc(lock+1);303 locktext = g_new(char, lock+1); 306 304 strncpy(locktext, e->buff, lock); 307 305 locktext[lock] = 0; … … 382 380 owl_editwin_excursion *owl_editwin_begin_excursion(owl_editwin *e) 383 381 { 384 owl_editwin_excursion *x = owl_malloc(sizeof *x);382 owl_editwin_excursion *x = g_new(owl_editwin_excursion, 1); 385 383 oe_save_excursion(e, x); 386 384 return x; … … 747 745 return; 748 746 749 tmp = owl_malloc((end - start) + 1);747 tmp = g_new(char, (end - start) + 1); 750 748 tmp[(end - start)] = 0; 751 749 memcpy(tmp, middle, end - middle); … … 1072 1070 char *killbuf = owl_global_get_kill_buffer(&g); 1073 1071 1074 p = owl_malloc(len + 1);1072 p = g_new(char, len + 1); 1075 1073 1076 1074 if (p != NULL) { … … 1408 1406 char *p; 1409 1407 1410 p = owl_malloc(end - start + 1);1408 p = g_new(char, end - start + 1); 1411 1409 memcpy(p, e->buff + start, end - start); 1412 1410 p[end - start] = 0; -
filter.c
r75c7e8e r96828e4 19 19 owl_filter *f; 20 20 21 f = owl_malloc(sizeof(owl_filter));21 f = g_new(owl_filter, 1); 22 22 23 23 f->name=owl_strdup(name); … … 70 70 if(!argc) return NULL; 71 71 72 fe = owl_malloc(sizeof(owl_filterelement));72 fe = g_new(owl_filterelement, 1); 73 73 owl_filterelement_create(fe); 74 74 … … 133 133 op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip); 134 134 if(!op2) goto err; 135 tmp = owl_malloc(sizeof(owl_filterelement));135 tmp = g_new(owl_filterelement, 1); 136 136 if(!strcasecmp(argv[i], "and")) { 137 137 owl_filterelement_create_and(tmp, op1, op2); -
fmtext.c
r099597c r96828e4 640 640 } else if (ptr[0]=='@') { 641 641 /* add the text up to this point then deal with the stack */ 642 buff= owl_malloc(ptr-txtptr+20);642 buff=g_new(char, ptr-txtptr+20); 643 643 strncpy(buff, txtptr, ptr-txtptr); 644 644 buff[ptr-txtptr]='\0'; … … 675 675 /* check what command we've got, push it on the stack, start 676 676 using it, and continue ... unless it's a color command */ 677 buff= owl_malloc(tmpptr-ptr+20);677 buff=g_new(char, tmpptr-ptr+20); 678 678 strncpy(buff, ptr, tmpptr-ptr); 679 679 buff[tmpptr-ptr]='\0'; … … 738 738 739 739 /* grab the color name */ 740 buff= owl_malloc(tmpptr-txtptr+20);740 buff=g_new(char, tmpptr-txtptr+20); 741 741 strncpy(buff, txtptr, tmpptr-txtptr); 742 742 buff[tmpptr-txtptr]='\0'; … … 765 765 } else if (ptr[0]=='}' || ptr[0]==']' || ptr[0]==')' || ptr[0]=='>') { 766 766 /* add the text up to this point first */ 767 buff= owl_malloc(ptr-txtptr+20);767 buff=g_new(char, ptr-txtptr+20); 768 768 strncpy(buff, txtptr, ptr-txtptr); 769 769 buff[ptr-txtptr]='\0'; … … 776 776 /* first, if the stack is empty we must bail (just print and go) */ 777 777 if (stacksize==0) { 778 buff= owl_malloc(5);778 buff=g_new(char, 5); 779 779 buff[0]=ptr[0]; 780 780 buff[1]='\0'; … … 802 802 } else { 803 803 /* otherwise print and continue */ 804 buff= owl_malloc(5);804 buff=g_new(char, 5); 805 805 buff[0]=ptr[0]; 806 806 buff[1]='\0'; … … 812 812 } else { 813 813 /* we've found an unattached opener, print everything and move on */ 814 buff= owl_malloc(ptr-txtptr+20);814 buff=g_new(char, ptr-txtptr+20); 815 815 strncpy(buff, txtptr, ptr-txtptr+1); 816 816 buff[ptr-txtptr+1]='\0'; … … 864 864 short i; 865 865 /* The test is <= because we allocate COLORS+1 entries. */ 866 cpmgr->pairs = owl_malloc((COLORS+1) * sizeof(short*));866 cpmgr->pairs = g_new(short *, COLORS + 1); 867 867 for(i = 0; i <= COLORS; i++) { 868 cpmgr->pairs[i] = owl_malloc((COLORS+1) * sizeof(short));868 cpmgr->pairs[i] = g_new(short, COLORS + 1); 869 869 } 870 870 owl_fmtext_reset_colorpairs(cpmgr); -
functions.c
r9518a85 r96828e4 234 234 owl_message *m; 235 235 236 m= owl_malloc(sizeof(owl_message));236 m=g_new(owl_message, 1); 237 237 owl_message_create_admin(m, header, body); 238 238 … … 257 257 258 258 /* create the message */ 259 m= owl_malloc(sizeof(owl_message));259 m=g_new(owl_message, 1); 260 260 owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z)); 261 261 … … 275 275 if (!owl_global_is_aimloggedin(&g)) return(NULL); 276 276 277 m= owl_malloc(sizeof(owl_message));277 m=g_new(owl_message, 1); 278 278 owl_message_create_aim(m, 279 279 owl_global_get_aim_screenname(&g), … … 294 294 295 295 /* create the message */ 296 m= owl_malloc(sizeof(owl_message));296 m=g_new(owl_message, 1); 297 297 owl_message_create_loopback(m, body); 298 298 owl_message_set_direction_out(m); … … 553 553 /* create a message and put it on the message queue. This simulates 554 554 * an incoming message */ 555 min= owl_malloc(sizeof(owl_message));555 min=g_new(owl_message, 1); 556 556 mout=owl_function_make_outgoing_loopback(msg); 557 557 … … 3457 3457 for (i = 0; i < j; i++) { 3458 3458 user = owl_list_get_element(&anyone, i); 3459 zald = owl_malloc(sizeof(ZAsyncLocateData_t));3459 zald = g_new(ZAsyncLocateData_t, 1); 3460 3460 if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) { 3461 3461 *zaldlist = g_list_append(*zaldlist, zald); -
global.c
rd3941a0 r96828e4 568 568 569 569 void owl_global_add_filter(owl_global *g, owl_filter *f) { 570 owl_global_filter_ent *e = owl_malloc(sizeof *e);570 owl_global_filter_ent *e = g_new(owl_global_filter_ent, 1); 571 571 e->g = g; 572 572 e->f = f; -
keybinding.c
rd275eb2 r96828e4 45 45 return(-1); 46 46 } 47 kb->keys = owl_malloc(nktokens*sizeof(int));47 kb->keys = g_new(int, nktokens); 48 48 for (i=0; i<nktokens; i++) { 49 49 kb->keys[i] = owl_keypress_fromstring(ktokens[i]); -
keymap.c
r44cc9ab r96828e4 38 38 int i; 39 39 40 if ((kb = owl_malloc(sizeof(owl_keybinding))) == NULL) return(-1);40 if ((kb = g_new(owl_keybinding, 1)) == NULL) return(-1); 41 41 if (0 != owl_keybinding_init(kb, keyseq, command, function_fn, desc)) { 42 42 owl_free(kb); … … 63 63 int i; 64 64 65 if ((kb = owl_malloc(sizeof(owl_keybinding))) == NULL) return(-1);65 if ((kb = g_new(owl_keybinding, 1)) == NULL) return(-1); 66 66 if (0 != owl_keybinding_make_keys(kb, keyseq)) { 67 67 owl_free(kb); … … 197 197 { 198 198 owl_keymap *km; 199 km = owl_malloc(sizeof(owl_keymap));199 km = g_new(owl_keymap, 1); 200 200 if (!km) return NULL; 201 201 owl_keymap_init(km, name, desc, default_fn, prealways_fn, postalways_fn); -
list.c
r5e5f08f r96828e4 8 8 { 9 9 l->size=0; 10 l->list= owl_malloc(INITSIZE*sizeof(void *));10 l->list=g_new(void *, INITSIZE); 11 11 l->avail=INITSIZE; 12 12 if (l->list==NULL) return(-1); -
logging.c
rc366cbd r96828e4 182 182 * owl_log_shouldlog_message(void) 183 183 */ 184 m = owl_malloc(sizeof(owl_message));184 m = g_new(owl_message, 1); 185 185 owl_message_create_from_zwrite(m, zw, text); 186 186 if (!owl_log_shouldlog_message(m)) { -
message.c
r719119de r96828e4 75 75 76 76 if(pair == NULL) { 77 pair = owl_malloc(sizeof(owl_pair));77 pair = g_new(owl_pair, 1); 78 78 owl_pair_create(pair, attrname, NULL); 79 79 owl_list_append_element(&(m->attributes), pair); -
perlconfig.c
rc107129 r96828e4 193 193 hash = (HV*)SvRV(msg); 194 194 195 m = owl_malloc(sizeof(owl_message));195 m = g_new(owl_message, 1); 196 196 owl_message_init(m); 197 197 -
perlglue.xs
r40382e0 r96828e4 43 43 rv = owl_function_command(cmd); 44 44 } else { 45 argv = owl_malloc((items + 1) * sizeof *argv);45 argv = g_new(const char *, items + 1); 46 46 argv[0] = cmd; 47 47 for(i = 1; i < items; i++) { … … 287 287 CODE: 288 288 { 289 s = owl_malloc(sizeof(owl_style));289 s = g_new(owl_style, 1); 290 290 owl_style_create_perl(s, name, newSVsv(object)); 291 291 owl_global_add_style(&g, s); -
popexec.c
r9eb38bb r96828e4 22 22 } 23 23 24 pe = owl_malloc(sizeof(owl_popexec));24 pe = g_new(owl_popexec, 1); 25 25 if (!pe) return NULL; 26 26 pe->winactive=0; … … 126 126 if (navail<=0) return; 127 127 if (navail>1024) { navail = 1024; } 128 buf = owl_malloc(navail+1);128 buf = g_new(char, navail+1); 129 129 owl_function_debugmsg("about to read %d", navail); 130 130 bread = read(d->fd, buf, navail); -
popwin.c
r9b9efa2b r96828e4 3 3 owl_popwin *owl_popwin_new(void) 4 4 { 5 owl_popwin *pw = owl_malloc(sizeof(owl_popwin)); 6 memset(pw, 0, sizeof(*pw)); 5 owl_popwin *pw = g_new0(owl_popwin, 1); 7 6 8 7 pw->border = owl_window_new(NULL); -
select.c
ra409a9d r96828e4 15 15 owl_timer *owl_select_add_timer(const char* name, int after, int interval, void (*cb)(owl_timer *, void *), void (*destroy)(owl_timer*), void *data) 16 16 { 17 owl_timer *t = owl_malloc(sizeof(owl_timer));17 owl_timer *t = g_new(owl_timer, 1); 18 18 GList **timers = owl_global_get_timerlist(&g); 19 19 … … 159 159 const owl_io_dispatch *owl_select_add_io_dispatch(int fd, int mode, void (*cb)(const owl_io_dispatch *, void *), void (*destroy)(const owl_io_dispatch *), void *data) 160 160 { 161 owl_io_dispatch *d = owl_malloc(sizeof(owl_io_dispatch));161 owl_io_dispatch *d = g_new(owl_io_dispatch, 1); 162 162 owl_list *dl = owl_global_get_io_dispatch_list(&g); 163 163 … … 299 299 owl_ps_action *owl_select_add_pre_select_action(int (*cb)(owl_ps_action *, void *), void (*destroy)(owl_ps_action *), void *data) 300 300 { 301 owl_ps_action *a = owl_malloc(sizeof(owl_ps_action));301 owl_ps_action *a = g_new(owl_ps_action, 1); 302 302 owl_list *psa_list = owl_global_get_psa_list(&g); 303 303 a->needs_gc = 0; -
text.c
r4d24650 r96828e4 53 53 char *out, *out2; 54 54 55 out= owl_malloc(strlen(in)+30);55 out=g_new(char, strlen(in)+30); 56 56 strcpy(out, ""); 57 57 … … 156 156 } 157 157 158 ret = owl_malloc(len + 1);158 ret = g_new(char, len + 1); 159 159 160 160 p = in; … … 281 281 tolen = strlen(to); 282 282 fromlen = strlen(from); 283 out = owl_malloc(outlen);283 out = g_new(char, outlen); 284 284 285 285 while (in[inpos]) { … … 335 335 escape++; 336 336 } 337 out = owl_malloc(in_len + quotestr_len*escape+1);337 out = g_new(char, in_len + quotestr_len*escape+1); 338 338 for (i=0; i<in_len; i++) { 339 339 -
util.c
r6965867 r96828e4 41 41 struct passwd *pw; 42 42 43 out= owl_malloc(MAXPATHLEN+1);43 out=g_new(char, MAXPATHLEN+1); 44 44 out[0]='\0'; 45 45 j=strlen(in); … … 294 294 /* hooks for doing memory allocation et. al. in owl */ 295 295 296 void *owl_malloc(size_t size)297 {298 return(g_malloc(size));299 }300 301 296 void owl_free(void *ptr) 302 297 { … … 593 588 if (g_utf8_validate(in, -1, NULL)) { 594 589 const char *s, *p; 595 r = owl_malloc(strlen(in)+1);590 r = g_new(char, strlen(in)+1); 596 591 r[0] = '\0'; 597 592 s = in; … … 718 713 /* Read a line from fp, allocating memory to hold it, returning the number of 719 714 * byte read. *s should either be NULL or a pointer to memory allocated with 720 * owl_malloc; it will be owl_realloc'd as appropriate. The caller must715 * g_malloc; it will be owl_realloc'd as appropriate. The caller must 721 716 * eventually free it. (This is roughly the interface of getline in the gnu 722 717 * libc). -
variable.c
rd275eb2 r96828e4 479 479 if (owl_dict_create(vd)) return(-1); 480 480 for (var = variables_to_init; var->name != NULL; var++) { 481 cur = owl_malloc(sizeof(owl_variable));481 cur = g_new(owl_variable, 1); 482 482 *cur = *var; 483 483 /* strdup all the strings so we can delete them consistently. */ … … 517 517 if (!cur->delete_fn) 518 518 cur->delete_fn = owl_variable_delete_default; 519 cur->val = owl_malloc(sizeof(int));519 cur->val = g_new(int, 1); 520 520 cur->set_fn(cur, &cur->ival_default); 521 521 break; … … 533 533 if (!cur->delete_fn) 534 534 cur->delete_fn = owl_variable_delete_default; 535 cur->val = owl_malloc(sizeof(int));535 cur->val = g_new(int, 1); 536 536 cur->set_fn(cur, &cur->ival_default); 537 537 break; … … 551 551 552 552 owl_variable * owl_variable_newvar(const char *name, const char *summary, const char * description) { 553 owl_variable * var = owl_malloc(sizeof(owl_variable)); 554 memset(var, 0, sizeof(owl_variable)); 553 owl_variable * var = g_new0(owl_variable, 1); 555 554 var->name = owl_strdup(name); 556 555 var->summary = owl_strdup(summary); … … 601 600 var->get_tostring_fn = owl_variable_int_get_tostring_default; 602 601 var->delete_fn = owl_variable_delete_default; 603 var->val = owl_malloc(sizeof(int));602 var->val = g_new(int, 1); 604 603 var->set_fn(var, &initval); 605 604 owl_variable_dict_add_variable(vd, var); … … 622 621 var->get_tostring_fn = owl_variable_bool_get_tostring_default; 623 622 var->delete_fn = owl_variable_delete_default; 624 var->val = owl_malloc(sizeof(int));623 var->val = g_new(int, 1); 625 624 var->set_fn(var, &initval); 626 625 owl_variable_dict_add_variable(vd, var); -
viewwin.c
rcedbe9d r96828e4 14 14 owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text) 15 15 { 16 owl_viewwin *v = owl_malloc(sizeof(owl_viewwin)); 17 memset(v, 0, sizeof(*v)); 16 owl_viewwin *v = g_new0(owl_viewwin, 1); 18 17 owl_fmtext_init_null(&(v->fmtext)); 19 18 if (text) { … … 38 37 { 39 38 char *text; 40 owl_viewwin *v = owl_malloc(sizeof(owl_viewwin)); 41 memset(v, 0, sizeof(*v)); 39 owl_viewwin *v = g_new0(owl_viewwin, 1); 42 40 43 41 owl_fmtext_copy(&(v->fmtext), fmtext); … … 197 195 owl_editwin_insert_string(tw, buffstart); 198 196 199 data = owl_malloc(sizeof(owl_viewwin_search_data));197 data = g_new(owl_viewwin_search_data, 1); 200 198 data->v = v; 201 199 data->direction = direction; -
zephyr.c
rdf3a1f4 r96828e4 229 229 owl_free(subs); 230 230 } else { 231 owl_sub_list *s = owl_malloc(sizeof(owl_sub_list));231 owl_sub_list *s = g_new(owl_sub_list, 1); 232 232 s->subs = subs; 233 233 s->nsubs = count; … … 259 259 struct stat statbuff; 260 260 261 subs = owl_malloc(sizeof(ZSubscription_t) *subSize);261 subs = g_new(ZSubscription_t, subSize); 262 262 subsfile = owl_zephyr_dotfile(".zephyr.subs", filename); 263 263 … … 333 333 int count, ret; 334 334 335 subs = owl_malloc(sizeof(ZSubscription_t) *subSize);335 subs = g_new(ZSubscription_t, subSize); 336 336 ZResetAuthentication(); 337 337 count=0; … … 377 377 struct stat statbuff; 378 378 379 subs = owl_malloc(numSubs * sizeof(ZSubscription_t));379 subs = g_new(ZSubscription_t, numSubs); 380 380 subsfile = owl_zephyr_dotfile(".anyone", filename); 381 381 … … 694 694 695 695 notice.z_message_len=strlen(zsig)+1+strlen(message); 696 notice.z_message= owl_malloc(notice.z_message_len+10);696 notice.z_message=g_new(char, notice.z_message_len+10); 697 697 strcpy(notice.z_message, zsig); 698 698 memcpy(notice.z_message+strlen(zsig)+1, message, strlen(message)); … … 1333 1333 if (ret == ZERR_NONE) { 1334 1334 /* Send a PSEUDO LOGIN! */ 1335 m = owl_malloc(sizeof(owl_message));1335 m = g_new(owl_message, 1); 1336 1336 owl_message_create_pseudo_zlogin(m, 0, zald->user, 1337 1337 location.host, … … 1346 1346 /* Send a PSEUDO LOGOUT! */ 1347 1347 if (notify) { 1348 m = owl_malloc(sizeof(owl_message));1348 m = g_new(owl_message, 1); 1349 1349 owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", ""); 1350 1350 owl_global_messagequeue_addmsg(&g, m); … … 1421 1421 1422 1422 /* create the new message */ 1423 m= owl_malloc(sizeof(owl_message));1423 m=g_new(owl_message, 1); 1424 1424 owl_message_create_from_znotice(m, ¬ice); 1425 1425 -
zwrite.c
rc6b1782 r96828e4 7 7 owl_zwrite *owl_zwrite_new(const char *line) 8 8 { 9 owl_zwrite *z = owl_malloc(sizeof *z);9 owl_zwrite *z = g_new(owl_zwrite, 1); 10 10 if (owl_zwrite_create_from_line(z, line) < 0) { 11 11 owl_zwrite_delete(z);
Note: See TracChangeset
for help on using the changeset viewer.