Changeset d8e2f07


Ignore:
Timestamp:
Jun 25, 2011, 4:11:19 AM (10 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
95b52d1 (diff), 2560529 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 2560529186e398f85a038e8683d29058857eb7b7 into 95b52d17a566adefc77f07749218fe0cb33a66b2
Files:
1 deleted
36 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r4f746f8 rc266281  
    3838           $(GIT_FLAGS)
    3939
    40 CODELIST_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
     40CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \
    4141     commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
    4242     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
  • aim.c

    rd427f08 re4524da  
    437437
    438438/* caller must free the return */
    439 G_GNUC_WARN_UNUSED_RESULT char *owl_aim_normalize_screenname(const char *in)
     439CALLER_OWN char *owl_aim_normalize_screenname(const char *in)
    440440{
    441441  char *out;
     
    14391439  const char *address, *SNs;
    14401440  int num, i;
    1441   owl_list list;
     1441  GPtrArray *list;
    14421442 
    14431443  va_start(ap, fr);
     
    14471447  va_end(ap);
    14481448
    1449   owl_list_create(&list);
     1449  list = g_ptr_array_new();
    14501450 
    14511451  owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address);
    14521452  for (i=0; i<num; i++) {
    14531453    owl_function_debugmsg("  %s", &SNs[i*(MAXSNLEN+1)]);
    1454     owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]);
    1455   }
    1456   owl_function_aimsearch_results(address, &list);
    1457   owl_list_cleanup(&list, NULL);
    1458   return(1);
     1454    g_ptr_array_add(list, (void *)&SNs[i*(MAXSNLEN+1)]);
     1455  }
     1456  owl_function_aimsearch_results(address, list);
     1457  g_ptr_array_free(list, true);
     1458  return 1;
    14591459}
    14601460
  • buddylist.c

    r96828e4 r3cdd6d2  
    33void owl_buddylist_init(owl_buddylist *bl)
    44{
    5   owl_list_create(&(bl->buddies));
     5  bl->buddies = g_ptr_array_new();
    66}
    77
     
    1414 
    1515  owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname);
    16   owl_list_append_element(&(bl->buddies), b);
     16  g_ptr_array_add(bl->buddies, b);
    1717}
    1818
     
    2121int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, const char *name)
    2222{
    23   int i, j;
     23  int i;
    2424  owl_buddy *b;
    2525
    26   j=owl_list_get_size(&(bl->buddies));
    27   for (i=0; i<j; i++) {
    28     b=owl_list_get_element(&(bl->buddies), i);
     26  for (i = 0; i < bl->buddies->len; i++) {
     27    b = bl->buddies->pdata[i];
    2928    if (!strcasecmp(name, owl_buddy_get_name(b)) && owl_buddy_is_proto_aim(b)) {
    30       owl_list_remove_element(&(bl->buddies), i);
    31       owl_buddy_delete(b);
     29      owl_buddy_delete(g_ptr_array_remove_index(bl->buddies, i));
    3230      return(0);
    3331    }
     
    8785int owl_buddylist_get_size(const owl_buddylist *bl)
    8886{
    89   return(owl_list_get_size(&(bl->buddies)));
     87  return bl->buddies->len;
    9088}
    9189
     
    9795  if (index>(owl_buddylist_get_size(bl)-1)) return(NULL);
    9896
    99   return(owl_list_get_element(&(bl->buddies), index));
     97  return bl->buddies->pdata[index];
    10098}
    10199
     
    105103owl_buddy *owl_buddylist_get_aim_buddy(const owl_buddylist *bl, const char *name)
    106104{
    107   int i, j;
     105  int i;
    108106  owl_buddy *b;
    109107
    110   j=owl_list_get_size(&(bl->buddies));
    111   for (i=0; i<j; i++) {
    112     b=owl_list_get_element(&(bl->buddies), i);
     108  for (i = 0; i < bl->buddies->len; i++) {
     109    b = bl->buddies->pdata[i];
    113110    if (!strcasecmp(name, owl_buddy_get_name(b))) return(b);
    114111  }
     
    131128void owl_buddylist_clear(owl_buddylist *bl)
    132129{
    133   owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);
    134   owl_list_create(&(bl->buddies));
     130  g_ptr_array_foreach(bl->buddies, (GFunc)owl_buddy_delete, NULL);
     131  g_ptr_array_set_size(bl->buddies, 0);
    135132}
    136133
    137134void owl_buddylist_cleanup(owl_buddylist *bl)
    138135{
    139   owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);
     136  owl_ptr_array_free(bl->buddies, (GDestroyNotify)owl_buddy_delete);
    140137}
  • cmd.c

    rd427f08 rce68f23  
    2828}
    2929
    30 void owl_cmddict_get_names(const owl_cmddict *d, owl_list *l) {
    31   owl_dict_get_keys(d, l);
     30GPtrArray *owl_cmddict_get_names(const owl_cmddict *d) {
     31  return owl_dict_get_keys(d);
    3232}
    3333
     
    5656
    5757/* caller must free the return */
    58 G_GNUC_WARN_UNUSED_RESULT char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)
     58CALLER_OWN char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)
    5959{
    6060  char *retval = NULL;
     
    7373
    7474/* caller must free the return */
    75 G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
     75CALLER_OWN char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
    7676{
    7777  char **argv;
     
    9797
    9898/* caller must free the return */
    99 G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)
     99CALLER_OWN char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)
    100100{
    101101  char *buff;
     
    154154
    155155/* caller must free the result */
    156 G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff)
     156CALLER_OWN char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff)
    157157{
    158158  static int alias_recurse_depth = 0;
     
    228228
    229229/* returns a summary line describing this keymap.  the caller must free. */
    230 G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_describe(const owl_cmd *cmd)
     230CALLER_OWN char *owl_cmd_describe(const owl_cmd *cmd)
    231231{
    232232  if (!cmd || !cmd->name || !cmd->summary) return NULL;
  • commands.c

    rb470451 re6d7e4e  
    13731373}
    13741374
    1375 G_GNUC_WARN_UNUSED_RESULT char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
     1375CALLER_OWN char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
    13761376{
    13771377  char *filtname = NULL;
     
    14131413}
    14141414
    1415 G_GNUC_WARN_UNUSED_RESULT char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
     1415CALLER_OWN char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
    14161416{
    14171417  if(argc != 1)
     
    16441644
    16451645
    1646 G_GNUC_WARN_UNUSED_RESULT char *owl_command_exec(int argc, const char *const *argv, const char *buff)
     1646CALLER_OWN char *owl_command_exec(int argc, const char *const *argv, const char *buff)
    16471647{
    16481648  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_RETURN);
    16491649}
    16501650
    1651 G_GNUC_WARN_UNUSED_RESULT char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
     1651CALLER_OWN char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
    16521652{
    16531653  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_POPUP);
    16541654}
    16551655
    1656 G_GNUC_WARN_UNUSED_RESULT char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
     1656CALLER_OWN char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
    16571657{
    16581658  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16591659}
    16601660
    1661 G_GNUC_WARN_UNUSED_RESULT char *owl_command_perl(int argc, const char *const *argv, const char *buff)
     1661CALLER_OWN char *owl_command_perl(int argc, const char *const *argv, const char *buff)
    16621662{
    16631663  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_RETURN);
    16641664}
    16651665
    1666 G_GNUC_WARN_UNUSED_RESULT char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
     1666CALLER_OWN char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
    16671667{
    16681668  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_POPUP);
    16691669}
    16701670
    1671 G_GNUC_WARN_UNUSED_RESULT char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
     1671CALLER_OWN char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
    16721672{
    16731673  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16741674}
    16751675
    1676 G_GNUC_WARN_UNUSED_RESULT char *owl_command_multi(int argc, const char *const *argv, const char *buff)
     1676CALLER_OWN char *owl_command_multi(int argc, const char *const *argv, const char *buff)
    16771677{
    16781678  char *lastrv = NULL, *newbuff;
     
    24672467void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt)
    24682468{
    2469   owl_list * fl;
    2470   owl_filter * f;
     2469  GPtrArray * fl;
    24712470  int i;
    24722471
     
    24782477    if(unpunt && (i=atoi(argv[1])) !=0) {
    24792478      i--;      /* Accept 1-based indexing */
    2480       if(i < owl_list_get_size(fl)) {
    2481         f = owl_list_get_element(fl, i);
    2482         owl_list_remove_element(fl, i);
    2483         owl_filter_delete(f);
     2479      if (i < fl->len) {
     2480        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    24842481        return;
    24852482      } else {
     
    25942591}
    25952592
    2596 G_GNUC_WARN_UNUSED_RESULT char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
     2593CALLER_OWN char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
    25972594{
    25982595  const char *stylename;
     
    26372634}
    26382635
    2639 G_GNUC_WARN_UNUSED_RESULT char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
     2636CALLER_OWN char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
    26402637{
    26412638  owl_history *hist;
  • context.c

    rd427f08 r6829afc  
    66
    77/* TODO: dependency from owl_context -> owl_window is annoying. */
    8 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
     8CALLER_OWN owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
    99{
    1010  owl_context *c;
  • dict.c

    rd427f08 rce68f23  
    5656}
    5757
    58 /* Appends dictionary keys to a list.  Duplicates the keys,
    59  * so they will need to be freed by the caller. */
    60 void owl_dict_get_keys(const owl_dict *d, owl_list *l) {
     58/* Returns a GPtrArray of dictionary keys. Duplicates the keys, so
     59 * they will need to be freed by the caller with g_free. */
     60CALLER_OWN GPtrArray *owl_dict_get_keys(const owl_dict *d) {
     61  GPtrArray *keys = g_ptr_array_sized_new(d->size);
    6162  int i;
    62   for (i=0; i<d->size; i++) {
    63     owl_list_append_element(l, g_strdup(d->els[i].k));
     63  for (i = 0; i < d->size; i++) {
     64    g_ptr_array_add(keys, g_strdup(d->els[i].k));
    6465  }
     66  return keys;
    6567}
    6668
     
    107109/* Doesn't free the value of the element, but does
    108110 * return it so the caller can free it. */
    109 G_GNUC_WARN_UNUSED_RESULT void *owl_dict_remove_element(owl_dict *d, const char *k)
     111CALLER_OWN void *owl_dict_remove_element(owl_dict *d, const char *k)
    110112{
    111113  int i;
  • editcontext.c

    rd427f08 r6829afc  
    88}
    99
    10 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
     10CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
    1111{
    1212  owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
  • editwin.c

    rd427f08 r6829afc  
    6161static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len);
    6262static int oe_copy_region(owl_editwin *e);
    63 static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end);
     63static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end);
    6464static void oe_destroy_cbdata(owl_editwin *e);
    6565static void oe_dirty(owl_editwin *e);
     
    7070#define WHITESPACE " \n\t"
    7171
    72 static G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_allocate(void)
     72static CALLER_OWN owl_editwin *owl_editwin_allocate(void)
    7373{
    7474  owl_editwin *e = g_new0(owl_editwin, 1);
     
    142142}
    143143
    144 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
     144CALLER_OWN owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
    145145{
    146146  owl_editwin *e = owl_editwin_allocate();
     
    13691369}
    13701370
    1371 G_GNUC_WARN_UNUSED_RESULT char *owl_editwin_get_region(owl_editwin *e)
     1371CALLER_OWN char *owl_editwin_get_region(owl_editwin *e)
    13721372{
    13731373  int start, end;
     
    13881388}
    13891389
    1390 static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end)
     1390static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end)
    13911391{
    13921392  char *p;
  • errqueue.c

    rd4927a7 reb897c6  
    33void owl_errqueue_init(owl_errqueue *eq)
    44{
    5   owl_list_create(&(eq->errlist));
     5  eq->errlist = g_ptr_array_new();
    66}
    77
    88void owl_errqueue_append_err(owl_errqueue *eq, const char *msg)
    99{
    10   owl_list_append_element(&(eq->errlist), g_strdup(msg));
     10  g_ptr_array_add(eq->errlist, g_strdup(msg));
    1111}
    1212
     
    1414void owl_errqueue_to_fmtext(const owl_errqueue *eq, owl_fmtext *fm)
    1515{
    16   int i, j;
    17 
    18   j=owl_list_get_size(&(eq->errlist));
    19   for (i=0; i<j; i++) {
    20     owl_fmtext_append_normal(fm, owl_list_get_element(&(eq->errlist), i));
     16  int i;
     17  for (i = 0; i < eq->errlist->len; i++) {
     18    owl_fmtext_append_normal(fm, eq->errlist->pdata[i]);
    2119    owl_fmtext_append_normal(fm, "\n");
    2220  }
  • filter.c

    rd427f08 r2560529  
    200200
    201201
    202 char G_GNUC_WARN_UNUSED_RESULT *owl_filter_print(const owl_filter *f)
     202CALLER_OWN char *owl_filter_print(const owl_filter *f)
    203203{
    204204  GString *out = g_string_new("");
  • fmtext.c

    rd427f08 r2560529  
    171171 * freeing the return
    172172 */
    173 char G_GNUC_WARN_UNUSED_RESULT *owl_fmtext_print_plain(const owl_fmtext *f)
     173CALLER_OWN char *owl_fmtext_print_plain(const owl_fmtext *f)
    174174{
    175175  return owl_strip_format_chars(f->buff->str);
     
    755755 * If format_fn is specified, passes it the list element value
    756756 * and it will return a string which this needs to free. */
    757 void owl_fmtext_append_list(owl_fmtext *f, const owl_list *l, const char *join_with, char *(format_fn)(const char *))
    758 {
    759   int i, size;
     757void owl_fmtext_append_list(owl_fmtext *f, const GPtrArray *l, const char *join_with, char *(format_fn)(const char *))
     758{
     759  int i;
    760760  const char *elem;
    761761  char *text;
    762762
    763   size = owl_list_get_size(l);
    764   for (i=0; i<size; i++) {
    765     elem = owl_list_get_element(l,i);
     763  for (i = 0; i < l->len; i++) {
     764    elem = l->pdata[i];
    766765    if (elem && format_fn) {
    767766      text = format_fn(elem);
     
    773772      owl_fmtext_append_normal(f, elem);
    774773    }
    775     if ((i < size-1) && join_with) {
     774    if ((i < l->len - 1) && join_with) {
    776775      owl_fmtext_append_normal(f, join_with);
    777776    }
  • functions.c

    rb470451 rce68f23  
    1414#include "filterproc.h"
    1515
    16 G_GNUC_WARN_UNUSED_RESULT char *owl_function_command(const char *cmdbuff)
     16CALLER_OWN char *owl_function_command(const char *cmdbuff)
    1717{
    1818  owl_function_debugmsg("executing command: %s", cmdbuff);
     
    2121}
    2222
    23 G_GNUC_WARN_UNUSED_RESULT char *owl_function_command_argv(const char *const *argv, int argc)
     23CALLER_OWN char *owl_function_command_argv(const char *const *argv, int argc)
    2424{
    2525  return owl_cmddict_execute_argv(owl_global_get_cmddict(&g),
     
    4747void owl_function_show_commands(void)
    4848{
    49   owl_list l;
     49  GPtrArray *l;
    5050  owl_fmtext fm;
    5151
     
    5353  owl_fmtext_append_bold(&fm, "Commands:  ");
    5454  owl_fmtext_append_normal(&fm, "(use 'show command <name>' for details)\n");
    55   owl_list_create(&l);
    56   owl_cmddict_get_names(owl_global_get_cmddict(&g), &l);
    57   owl_fmtext_append_list(&fm, &l, "\n", owl_function_cmd_describe);
     55  l = owl_cmddict_get_names(owl_global_get_cmddict(&g));
     56  owl_fmtext_append_list(&fm, l, "\n", owl_function_cmd_describe);
    5857  owl_fmtext_append_normal(&fm, "\n");
    5958  owl_function_popless_fmtext(&fm);
    60   owl_list_cleanup(&l, g_free);
     59  owl_ptr_array_free(l, g_free);
    6160  owl_fmtext_cleanup(&fm);
    6261}
     
    8180
    8281void owl_function_show_styles(void) {
    83   owl_list l;
     82  GPtrArray *l;
    8483  owl_fmtext fm;
    8584
    8685  owl_fmtext_init_null(&fm);
    8786  owl_fmtext_append_bold(&fm, "Styles:\n");
    88   owl_list_create(&l);
    89   owl_global_get_style_names(&g, &l);
    90   owl_fmtext_append_list(&fm, &l, "\n", owl_function_style_describe);
     87  l = owl_global_get_style_names(&g);
     88  owl_fmtext_append_list(&fm, l, "\n", owl_function_style_describe);
    9189  owl_fmtext_append_normal(&fm, "\n");
    9290  owl_function_popless_fmtext(&fm);
    93   owl_list_cleanup(&l, g_free);
     91  owl_ptr_array_free(l, g_free);
    9492  owl_fmtext_cleanup(&fm);
    9593}
    9694
    97 G_GNUC_WARN_UNUSED_RESULT char *owl_function_style_describe(const char *name)
     95CALLER_OWN char *owl_function_style_describe(const char *name)
    9896{
    9997  const char *desc;
     
    112110}
    113111
    114 G_GNUC_WARN_UNUSED_RESULT char *owl_function_cmd_describe(const char *name)
     112CALLER_OWN char *owl_function_cmd_describe(const char *name)
    115113{
    116114  const owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    250248 * owl_global_messagequeue_addmsg() for that.
    251249 */
    252 G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
     250CALLER_OWN owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
    253251{
    254252  owl_message *m;
     
    271269 * owl_global_messagequeue_addmsg() for that.
    272270 */
    273 G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_loopback(const char *body)
     271CALLER_OWN owl_message *owl_function_make_outgoing_loopback(const char *body)
    274272{
    275273  owl_message *m;
     
    15761574  const char *name;
    15771575  char *var;
    1578   owl_list varnames;
    1579   int i, numvarnames;
     1576  GPtrArray *varnames;
     1577  int i;
    15801578  GString *str   = g_string_new("");
    15811579
    15821580  g_string_append_printf(str, "%-20s = %s\n", "VARIABLE", "VALUE");
    15831581  g_string_append_printf(str, "%-20s   %s\n",  "--------", "-----");
    1584   owl_list_create(&varnames);
    1585   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1586   numvarnames = owl_list_get_size(&varnames);
    1587   for (i=0; i<numvarnames; i++) {
    1588     name = owl_list_get_element(&varnames, i);
     1582  varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g));
     1583  for (i = 0; i < varnames->len; i++) {
     1584    name = varnames->pdata[i];
    15891585    if (name && name[0]!='_') {
    15901586      g_string_append_printf(str, "\n%-20s = ", name);
     
    15971593  }
    15981594  g_string_append(str, "\n");
    1599   owl_list_cleanup(&varnames, g_free);
     1595  owl_ptr_array_free(varnames, g_free);
    16001596
    16011597  owl_function_popless_text(str->str);
     
    16051601void owl_function_show_variables(void)
    16061602{
    1607   owl_list varnames;
     1603  GPtrArray *varnames;
    16081604  owl_fmtext fm; 
    1609   int i, numvarnames;
     1605  int i;
    16101606  const char *varname;
    16111607
     
    16131609  owl_fmtext_append_bold(&fm,
    16141610      "Variables: (use 'show variable <name>' for details)\n");
    1615   owl_list_create(&varnames);
    1616   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1617   numvarnames = owl_list_get_size(&varnames);
    1618   for (i=0; i<numvarnames; i++) {
    1619     varname = owl_list_get_element(&varnames, i);
     1611  varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g));
     1612  for (i = 0; i < varnames->len; i++) {
     1613    varname = varnames->pdata[i];
    16201614    if (varname && varname[0]!='_') {
    16211615      owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    16221616    }
    16231617  }
    1624   owl_list_cleanup(&varnames, g_free);
     1618  owl_ptr_array_free(varnames, g_free);
    16251619  owl_function_popless_fmtext(&fm);
    16261620  owl_fmtext_cleanup(&fm);
     
    19001894}
    19011895
    1902 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_question(const char *line)
     1896CALLER_OWN owl_editwin *owl_function_start_question(const char *line)
    19031897{
    19041898  owl_editwin *tw;
     
    19151909}
    19161910
    1917 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_password(const char *line)
     1911CALLER_OWN owl_editwin *owl_function_start_password(const char *line)
    19181912{
    19191913  owl_editwin *tw;
     
    19321926}
    19331927
    1934 G_GNUC_WARN_UNUSED_RESULT char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
     1928CALLER_OWN char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
    19351929{
    19361930  /* if type == 1 display in a popup
     
    19751969}
    19761970
    1977 G_GNUC_WARN_UNUSED_RESULT char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
     1971CALLER_OWN char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
    19781972{
    19791973  /* if type == 1 display in a popup
     
    21452139 * Returns the name of the negated filter, which the caller must free.
    21462140 */
    2147 G_GNUC_WARN_UNUSED_RESULT char *owl_function_create_negative_filter(const char *filtername)
     2141CALLER_OWN char *owl_function_create_negative_filter(const char *filtername)
    21482142{
    21492143  char *newname;
     
    22152209{
    22162210  const owl_filter *f;
    2217   const owl_list *fl;
     2211  const GPtrArray *fl;
    22182212  char *tmp;
    22192213  owl_fmtext fm;
    2220   int i, j;
     2214  int i;
    22212215
    22222216  owl_fmtext_init_null(&fm);
    22232217
    22242218  fl=owl_global_get_puntlist(&g);
    2225   j=owl_list_get_size(fl);
    22262219  owl_fmtext_append_bold(&fm, "Active zpunt filters:\n");
    22272220
    2228   for (i=0; i<j; i++) {
    2229     f=owl_list_get_element(fl, i);
     2221  for (i = 0; i < fl->len; i++) {
     2222    f = fl->pdata[i];
    22302223    owl_fmtext_appendf_normal(&fm, "[% 2d] ", i+1);
    22312224    tmp = owl_filter_print(f);
     
    22422235 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22432236 */
    2244 G_GNUC_WARN_UNUSED_RESULT char *owl_function_classinstfilt(const char *c, const char *i, int related)
     2237CALLER_OWN char *owl_function_classinstfilt(const char *c, const char *i, int related)
    22452238{
    22462239  owl_filter *f;
     
    23292322 * the filter, which the caller must free.
    23302323 */
    2331 G_GNUC_WARN_UNUSED_RESULT char *owl_function_zuserfilt(const char *longuser)
     2324CALLER_OWN char *owl_function_zuserfilt(const char *longuser)
    23322325{
    23332326  owl_filter *f;
     
    23752368 * Returns the name of the filter, which the caller must free.
    23762369 */
    2377 G_GNUC_WARN_UNUSED_RESULT char *owl_function_aimuserfilt(const char *user)
     2370CALLER_OWN char *owl_function_aimuserfilt(const char *user)
    23782371{
    23792372  owl_filter *f;
     
    24132406}
    24142407
    2415 G_GNUC_WARN_UNUSED_RESULT char *owl_function_typefilt(const char *type)
     2408CALLER_OWN char *owl_function_typefilt(const char *type)
    24162409{
    24172410  owl_filter *f;
     
    24692462}
    24702463
    2471 static G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter_cc(const owl_message *m)
     2464static CALLER_OWN char *owl_function_smartfilter_cc(const owl_message *m)
    24722465{
    24732466  const char *ccs;
     
    25212514 *    name to the AIM conversation with that user
    25222515 */
    2523 G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter(int type, int invert_related)
     2516CALLER_OWN char *owl_function_smartfilter(int type, int invert_related)
    25242517{
    25252518  const owl_view *v;
     
    27802773
    27812774  owl_function_punt(argv->len, (const char *const*) argv->pdata, direction);
    2782   g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
    2783   g_ptr_array_free(argv, true);
     2775  owl_ptr_array_free(argv, g_free);
    27842776}
    27852777
     
    27872779{
    27882780  owl_filter *f;
    2789   owl_list *fl;
    2790   int i, j;
     2781  GPtrArray *fl;
     2782  int i;
    27912783  fl=owl_global_get_puntlist(&g);
    27922784
     
    27992791
    28002792  /* Check for an identical filter */
    2801   j=owl_list_get_size(fl);
    2802   for (i=0; i<j; i++) {
    2803     if (owl_filter_equiv(f, owl_list_get_element(fl, i))) {
     2793  for (i = 0; i < fl->len; i++) {
     2794    if (owl_filter_equiv(f, fl->pdata[i])) {
    28042795      owl_function_debugmsg("found an equivalent punt filter");
    28052796      /* if we're punting, then just silently bow out on this duplicate */
     
    28112802      /* if we're unpunting, then remove this filter from the puntlist */
    28122803      if (direction==1) {
    2813         owl_filter_delete(owl_list_get_element(fl, i));
    2814         owl_list_remove_element(fl, i);
     2804        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    28152805        owl_filter_delete(f);
    28162806        return;
     
    28222812    owl_function_debugmsg("punting");
    28232813    /* If we're punting, add the filter to the global punt list */
    2824     owl_list_append_element(fl, f);
     2814    g_ptr_array_add(fl, f);
    28252815  } else if (direction == 1) {
    28262816    owl_function_makemsg("No matching punt filter");
     
    28302820void owl_function_show_keymaps(void)
    28312821{
    2832   owl_list l;
     2822  GPtrArray *l;
    28332823  owl_fmtext fm;
    28342824  const owl_keymap *km;
    28352825  const owl_keyhandler *kh;
    2836   int i, numkm;
     2826  int i;
    28372827  const char *kmname;
    28382828
     
    28412831  owl_fmtext_append_bold(&fm, "Keymaps:   ");
    28422832  owl_fmtext_append_normal(&fm, "(use 'show keymap <name>' for details)\n");
    2843   owl_list_create(&l);
    2844   owl_keyhandler_get_keymap_names(kh, &l);
    2845   owl_fmtext_append_list(&fm, &l, "\n", owl_function_keymap_summary);
     2833  l = owl_keyhandler_get_keymap_names(kh);
     2834  owl_fmtext_append_list(&fm, l, "\n", owl_function_keymap_summary);
    28462835  owl_fmtext_append_normal(&fm, "\n");
    28472836
    2848   numkm = owl_list_get_size(&l);
    2849   for (i=0; i<numkm; i++) {
    2850     kmname = owl_list_get_element(&l, i);
     2837  for (i = 0; i < l->len; i++) {
     2838    kmname = l->pdata[i];
    28512839    km = owl_keyhandler_get_keymap(kh, kmname);
    28522840    owl_fmtext_append_bold(&fm, "\n\n----------------------------------------------------------------------------------------------------\n\n");
     
    28562844 
    28572845  owl_function_popless_fmtext(&fm);
    2858   owl_list_cleanup(&l, g_free);
     2846  owl_ptr_array_free(l, g_free);
    28592847  owl_fmtext_cleanup(&fm);
    28602848}
    28612849
    2862 G_GNUC_WARN_UNUSED_RESULT char *owl_function_keymap_summary(const char *name)
     2850CALLER_OWN char *owl_function_keymap_summary(const char *name)
    28632851{
    28642852  const owl_keymap *km
     
    29742962/* strips formatting from ztext and returns the unformatted text.
    29752963 * caller is responsible for freeing. */
    2976 G_GNUC_WARN_UNUSED_RESULT char *owl_function_ztext_stylestrip(const char *zt)
     2964CALLER_OWN char *owl_function_ztext_stylestrip(const char *zt)
    29772965{
    29782966  owl_fmtext fm;
     
    29972985#ifdef HAVE_LIBZEPHYR
    29982986  int x;
    2999   owl_list anyone;
     2987  GPtrArray *anyone;
    30002988  const char *user;
    30012989  char *tmp;
     
    30323020    } else {
    30333021      owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n");
    3034       owl_list_create(&anyone);
    3035       ret=owl_zephyr_get_anyone_list(&anyone, filename);
    3036       if (ret) {
     3022      anyone = owl_zephyr_get_anyone_list(filename);
     3023      if (anyone == NULL) {
    30373024        if (errno == ENOENT) {
    30383025          owl_fmtext_append_normal(&fm, " You have not added any zephyr buddies.  Use the\n");
     
    30443031        }
    30453032      } else {
    3046         j=owl_list_get_size(&anyone);
    3047         for (i=0; i<j; i++) {
    3048           user=owl_list_get_element(&anyone, i);
     3033        for (i = 0; i < anyone->len; i++) {
     3034          user = anyone->pdata[i];
    30493035          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30503036
     
    30783064        }
    30793065      }
    3080       owl_list_cleanup(&anyone, g_free);
     3066      owl_ptr_array_free(anyone, g_free);
    30813067    }
    30823068  }
     
    33903376{
    33913377#ifdef HAVE_LIBZEPHYR
    3392   int i, j;
    3393   owl_list anyone;
     3378  int i;
     3379  GPtrArray *anyone;
    33943380  GList **zaldlist;
    33953381  GList *zaldptr;
     
    34113397  *zaldlist = NULL;
    34123398
    3413   owl_list_create(&anyone);
    3414   owl_zephyr_get_anyone_list(&anyone, NULL);
    3415   j = owl_list_get_size(&anyone);
    3416   for (i = 0; i < j; i++) {
    3417     user = owl_list_get_element(&anyone, i);
     3399  anyone = owl_zephyr_get_anyone_list(NULL);
     3400  for (i = 0; i < anyone->len; i++) {
     3401    user = anyone->pdata[i];
    34183402    zald = g_new(ZAsyncLocateData_t, 1);
    34193403    if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
     
    34243408  }
    34253409
    3426   owl_list_cleanup(&anyone, g_free);
     3410  owl_ptr_array_free(anyone, g_free);
    34273411#endif
    34283412}
    34293413
    3430 void owl_function_aimsearch_results(const char *email, owl_list *namelist)
     3414void owl_function_aimsearch_results(const char *email, GPtrArray *namelist)
    34313415{
    34323416  owl_fmtext fm;
    3433   int i, j;
     3417  int i;
    34343418
    34353419  owl_fmtext_init_null(&fm);
     
    34383422  owl_fmtext_append_normal(&fm, ":\n");
    34393423
    3440   j=owl_list_get_size(namelist);
    3441   for (i=0; i<j; i++) {
     3424  for (i = 0; i < namelist->len; i++) {
    34423425    owl_fmtext_append_normal(&fm, "  ");
    3443     owl_fmtext_append_normal(&fm, owl_list_get_element(namelist, i));
     3426    owl_fmtext_append_normal(&fm, namelist->pdata[i]);
    34443427    owl_fmtext_append_normal(&fm, "\n");
    34453428  }
  • global.c

    r43744ce r2560529  
    4747  owl_dict_create(&(g->filters));
    4848  g->filterlist = NULL;
    49   owl_list_create(&(g->puntlist));
     49  g->puntlist = g_ptr_array_new();
    5050  g->messagequeue = g_queue_new();
    5151  owl_dict_create(&(g->styledict));
     
    172172/* Pops the current context from the context stack and returns it. Caller is
    173173 * responsible for freeing. */
    174 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_global_pop_context_no_delete(owl_global *g)
     174CALLER_OWN owl_context *owl_global_pop_context_no_delete(owl_global *g)
    175175{
    176176  owl_context *c;
     
    579579/* puntlist */
    580580
    581 owl_list *owl_global_get_puntlist(owl_global *g) {
    582   return(&(g->puntlist));
     581GPtrArray *owl_global_get_puntlist(owl_global *g) {
     582  return g->puntlist;
    583583}
    584584
    585585int owl_global_message_is_puntable(owl_global *g, const owl_message *m) {
    586   const owl_list *pl;
    587   int i, j;
    588 
    589   pl=owl_global_get_puntlist(g);
    590   j=owl_list_get_size(pl);
    591   for (i=0; i<j; i++) {
    592     if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
    593   }
    594   return(0);
     586  const GPtrArray *pl;
     587  int i;
     588
     589  pl = owl_global_get_puntlist(g);
     590  for (i = 0; i < pl->len; i++) {
     591    if (owl_filter_message_match(pl->pdata[i], m)) return 1;
     592  }
     593  return 0;
    595594}
    596595
     
    725724 * necessary.
    726725 */
    727 owl_message G_GNUC_WARN_UNUSED_RESULT *owl_global_messagequeue_popmsg(owl_global *g)
     726CALLER_OWN owl_message *owl_global_messagequeue_popmsg(owl_global *g)
    728727{
    729728  owl_message *out;
     
    754753}
    755754
    756 void owl_global_get_style_names(const owl_global *g, owl_list *l) {
    757   owl_dict_get_keys(&(g->styledict), l);
     755CALLER_OWN GPtrArray *owl_global_get_style_names(const owl_global *g)
     756{
     757  return owl_dict_get_keys(&g->styledict);
    758758}
    759759
  • help.c

    rf25df21 rce68f23  
    66  owl_fmtext fm;
    77  const char *varname;
    8   owl_list varnames;
    9   int i, numvarnames;
     8  GPtrArray *varnames;
     9  int i;
    1010
    1111  owl_fmtext_init_null(&fm);
     
    129129  owl_fmtext_append_bold(&fm,
    130130                         "Variables:\n");
    131   owl_list_create(&varnames);
    132   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    133   numvarnames = owl_list_get_size(&varnames);
    134   for (i=0; i<numvarnames; i++) {
    135     varname = owl_list_get_element(&varnames, i);
     131  varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g));
     132  for (i = 0; i < varnames->len; i++) {
     133    varname = varnames->pdata[i];
    136134    if (varname && varname[0]!='_') {
    137135      owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    138136    }
    139137  }
    140   owl_list_cleanup(&varnames, g_free);
     138  owl_ptr_array_free(varnames, g_free);
    141139
    142140  owl_fmtext_append_normal(&fm, "\n");
  • keybinding.c

    rd427f08 r6829afc  
    1414
    1515/* sets up a new keybinding for a command */
    16 G_GNUC_WARN_UNUSED_RESULT owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
     16CALLER_OWN owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    1717{
    1818  owl_keybinding *kb = g_new(owl_keybinding, 1);
     
    8585}
    8686
    87 G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_stack_tostring(int *j, int len)
     87CALLER_OWN char *owl_keybinding_stack_tostring(int *j, int len)
    8888{
    8989  GString *string;
     
    100100}
    101101
    102 G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_tostring(const owl_keybinding *kb)
     102CALLER_OWN char *owl_keybinding_tostring(const owl_keybinding *kb)
    103103{
    104104  return owl_keybinding_stack_tostring(kb->keys, kb->len);
  • keymap.c

    rd427f08 rce68f23  
    1111  km->name = g_strdup(name);
    1212  km->desc = g_strdup(desc);
    13   owl_list_create(&km->bindings);
     13  km->bindings = g_ptr_array_new();
    1414  km->parent = NULL;
    1515  km->default_fn = default_fn;
     
    2424  g_free(km->name);
    2525  g_free(km->desc);
    26   owl_list_cleanup(&km->bindings, (void (*)(void *))owl_keybinding_delete);
     26  owl_ptr_array_free(km->bindings, (GDestroyNotify)owl_keybinding_delete);
    2727}
    2828
     
    3535int owl_keymap_create_binding(owl_keymap *km, const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    3636{
    37   owl_keybinding *kb, *curkb;
     37  owl_keybinding *kb;
    3838  int i;
    3939
     
    4444   * otherwise just add this one.
    4545   */
    46   for (i = owl_list_get_size(&km->bindings)-1; i>=0; i--) {
    47     curkb = owl_list_get_element(&km->bindings, i);
    48     if (owl_keybinding_equal(curkb, kb)) {
    49       owl_list_remove_element(&km->bindings, i);
    50       owl_keybinding_delete(curkb);
    51     }
    52   }
    53   owl_list_append_element(&km->bindings, kb);
     46  for (i = km->bindings->len-1; i >= 0; i--) {
     47    if (owl_keybinding_equal(km->bindings->pdata[i], kb)) {
     48      owl_keybinding_delete(g_ptr_array_remove_index(km->bindings, i));
     49    }
     50  }
     51  g_ptr_array_add(km->bindings, kb);
    5452  return 0;
    5553}
     
    5856int owl_keymap_remove_binding(owl_keymap *km, const char *keyseq)
    5957{
    60   owl_keybinding *kb, *curkb;
     58  owl_keybinding *kb;
    6159  int i;
    6260
     
    6563    return -1;
    6664
    67   for (i = owl_list_get_size(&km->bindings)-1; i >= 0; i--) {
    68     curkb = owl_list_get_element(&km->bindings, i);
    69     if (owl_keybinding_equal(curkb, kb)) {
    70       owl_list_remove_element(&km->bindings, i);
    71       owl_keybinding_delete(curkb);
     65  for (i = km->bindings->len-1; i >= 0; i--) {
     66    if (owl_keybinding_equal(km->bindings->pdata[i], kb)) {
     67      owl_keybinding_delete(g_ptr_array_remove_index(km->bindings, i));
    7268      owl_keybinding_delete(kb);
    7369      return(0);
     
    8076
    8177/* returns a summary line describing this keymap.  the caller must free. */
    82 G_GNUC_WARN_UNUSED_RESULT char *owl_keymap_summary(const owl_keymap *km)
     78CALLER_OWN char *owl_keymap_summary(const owl_keymap *km)
    8379{
    8480  if (!km || !km->name || !km->desc) return NULL;
     
    139135static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm)
    140136{
    141   int i, nbindings;
     137  int i;
    142138  const owl_keybinding *kb;
    143139 
    144   nbindings = owl_list_get_size(&km->bindings);
    145   for (i=0; i<nbindings; i++) {
     140  for (i = 0; i < km->bindings->len; i++) {
    146141    char *kbstr;
    147142    const owl_cmd *cmd;
    148143    const char *tmpdesc, *desc = "";
    149144
    150     kb = owl_list_get_element(&km->bindings, i);
     145    kb = km->bindings->pdata[i];
    151146    kbstr = owl_keybinding_tostring(kb);
    152147    owl_fmtext_append_normal(fm, OWL_TABSTR);
     
    214209}
    215210
    216 void owl_keyhandler_get_keymap_names(const owl_keyhandler *kh, owl_list *l)
    217 {
    218   owl_dict_get_keys(&kh->keymaps, l);
     211CALLER_OWN GPtrArray *owl_keyhandler_get_keymap_names(const owl_keyhandler *kh)
     212{
     213  return owl_dict_get_keys(&kh->keymaps);
    219214}
    220215
     
    274269   * keyhandler and keymap apart.  */
    275270  for (km=kh->active; km; km=km->parent) {
    276     for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) {
    277       kb = owl_list_get_element(&km->bindings, i);
     271    for (i = km->bindings->len-1; i >= 0; i--) {
     272      kb = km->bindings->pdata[i];
    278273      match = owl_keybinding_match(kb, kh);
    279274      if (match == 1) {         /* subset match */
  • keypress.c

    rd427f08 r2560529  
    129129/* OWL_META is definied in owl.h */
    130130
    131 char G_GNUC_WARN_UNUSED_RESULT *owl_keypress_tostring(int j, int esc)
     131CALLER_OWN char *owl_keypress_tostring(int j, int esc)
    132132{
    133133  GString *kb;
  • logging.c

    rd427f08 r6829afc  
    8080}
    8181
    82 G_GNUC_WARN_UNUSED_RESULT char *owl_log_zephyr(const owl_message *m)
     82CALLER_OWN char *owl_log_zephyr(const owl_message *m)
    8383{
    8484    char *tmp = NULL;
     
    104104}
    105105
    106 G_GNUC_WARN_UNUSED_RESULT char *owl_log_aim(const owl_message *m)
     106CALLER_OWN char *owl_log_aim(const owl_message *m)
    107107{
    108108    GString *buffer = NULL;
     
    122122}
    123123
    124 G_GNUC_WARN_UNUSED_RESULT char *owl_log_jabber(const owl_message *m)
     124CALLER_OWN char *owl_log_jabber(const owl_message *m)
    125125{
    126126    GString *buffer = NULL;
     
    135135}
    136136
    137 G_GNUC_WARN_UNUSED_RESULT char *owl_log_generic(const owl_message *m)
     137CALLER_OWN char *owl_log_generic(const owl_message *m)
    138138{
    139139    GString *buffer;
  • message.c

    rd427f08 rf9df2f0  
    4343
    4444  owl_message_set_hostname(m, "");
    45   owl_list_create(&(m->attributes));
     45  m->attributes = g_ptr_array_new();
    4646 
    4747  /* save the time */
     
    5858void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue)
    5959{
    60   int i, j;
     60  int i;
    6161  owl_pair *p = NULL, *pair = NULL;
    6262
     
    6464
    6565  /* look for an existing pair with this key, */
    66   j=owl_list_get_size(&(m->attributes));
    67   for (i=0; i<j; i++) {
    68     p=owl_list_get_element(&(m->attributes), i);
     66  for (i = 0; i < m->attributes->len; i++) {
     67    p = m->attributes->pdata[i];
    6968    if (owl_pair_get_key(p) == attrname) {
    7069      g_free(owl_pair_get_value(p));
     
    7776    pair = g_new(owl_pair, 1);
    7877    owl_pair_create(pair, attrname, NULL);
    79     owl_list_append_element(&(m->attributes), pair);
     78    g_ptr_array_add(m->attributes, pair);
    8079  }
    8180  owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
     
    8786const char *owl_message_get_attribute_value(const owl_message *m, const char *attrname)
    8887{
    89   int i, j;
     88  int i;
    9089  owl_pair *p;
    9190  GQuark quark;
     
    9796  attrname = g_quark_to_string(quark);
    9897
    99   j=owl_list_get_size(&(m->attributes));
    100   for (i=0; i<j; i++) {
    101     p=owl_list_get_element(&(m->attributes), i);
     98  for (i = 0; i < m->attributes->len; i++) {
     99    p = m->attributes->pdata[i];
    102100    if (owl_pair_get_key(p) == attrname) {
    103101      return(owl_pair_get_value(p));
     
    118116 */
    119117void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) {
    120   int i, j;
     118  int i;
    121119  owl_pair *p;
    122120  char *buff, *tmpbuff;
     
    124122  owl_fmtext_init_null(fm);
    125123
    126   j=owl_list_get_size(&(m->attributes));
    127   for (i=0; i<j; i++) {
    128     p=owl_list_get_element(&(m->attributes), i);
     124  for (i = 0; i < m->attributes->len; i++) {
     125    p = m->attributes->pdata[i];
    129126
    130127    tmpbuff = g_strdup(owl_pair_get_value(p));
     
    580577
    581578/* caller must free return value. */
    582 G_GNUC_WARN_UNUSED_RESULT char *owl_message_get_cc(const owl_message *m)
     579CALLER_OWN char *owl_message_get_cc(const owl_message *m)
    583580{
    584581  const char *cur;
     
    597594
    598595/* caller must free return value */
    599 G_GNUC_WARN_UNUSED_RESULT GList *owl_message_get_cc_without_recipient(const owl_message *m)
     596CALLER_OWN GList *owl_message_get_cc_without_recipient(const owl_message *m)
    600597{
    601598  char *cc, *shortuser, *recip;
     
    10041001void owl_message_cleanup(owl_message *m)
    10051002{
    1006   int i, j;
     1003  int i;
    10071004  owl_pair *p;
    10081005#ifdef HAVE_LIBZEPHYR   
     
    10141011
    10151012  /* free all the attributes */
    1016   j=owl_list_get_size(&(m->attributes));
    1017   for (i=0; i<j; i++) {
    1018     p=owl_list_get_element(&(m->attributes), i);
     1013  for (i = 0; i < m->attributes->len; i++) {
     1014    p = m->attributes->pdata[i];
    10191015    g_free(owl_pair_get_value(p));
    10201016    g_free(p);
    10211017  }
    10221018
    1023   owl_list_cleanup(&(m->attributes), NULL);
     1019  g_ptr_array_free(m->attributes, true);
    10241020 
    10251021  owl_message_invalidate_format(m);
  • messagelist.c

    rd427f08 rfc8a87a  
    33#include <string.h>
    44
    5 int owl_messagelist_create(owl_messagelist *ml)
     5void owl_messagelist_create(owl_messagelist *ml)
    66{
    7   owl_list_create(&(ml->list));
    8   return(0);
     7  ml->list = g_ptr_array_new();
     8}
     9
     10void owl_messagelist_cleanup(owl_messagelist *ml, bool free_messages)
     11{
     12  if (free_messages)
     13    g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL);
     14  g_ptr_array_free(ml->list, true);
    915}
    1016
    1117int owl_messagelist_get_size(const owl_messagelist *ml)
    1218{
    13   return(owl_list_get_size(&(ml->list)));
     19  return ml->list->len;
    1420}
    1521
    1622void *owl_messagelist_get_element(const owl_messagelist *ml, int n)
    1723{
    18   return(owl_list_get_element(&(ml->list), n));
     24  return ml->list->pdata[n];
    1925}
    2026
     
    2632
    2733  first = 0;
    28   last = owl_list_get_size(&(ml->list)) - 1;
     34  last = ml->list->len - 1;
    2935  while (first <= last) {
    3036    mid = (first + last) / 2;
    31     m = owl_list_get_element(&(ml->list), mid);
     37    m = ml->list->pdata[mid];
    3238    msg_id = owl_message_get_id(m);
    3339    if (msg_id == target_id) {
     
    4450void owl_messagelist_append_element(owl_messagelist *ml, void *element)
    4551{
    46   owl_list_append_element(&ml->list, element);
     52  g_ptr_array_add(ml->list, element);
    4753}
    4854
     
    5157{
    5258  /* mark a message as deleted */
    53   owl_message_mark_delete(owl_list_get_element(&(ml->list), n));
     59  owl_message_mark_delete(ml->list->pdata[n]);
    5460  return(0);
    5561}
     
    5864{
    5965  /* mark a message as deleted */
    60   owl_message_unmark_delete(owl_list_get_element(&(ml->list), n));
     66  owl_message_unmark_delete(ml->list->pdata[n]);
    6167  return(0);
    6268}
     
    6571{
    6672  /* expunge deleted messages */
    67   int i, j;
    68   owl_list newlist;
     73  int i;
     74  GPtrArray *newlist;
    6975  owl_message *m;
    7076
    71   owl_list_create(&newlist);
     77  newlist = g_ptr_array_new();
    7278  /*create a new list without messages marked as deleted */
    73   j=owl_list_get_size(&(ml->list));
    74   for (i=0; i<j; i++) {
    75     m=owl_list_get_element(&(ml->list), i);
     79  for (i = 0; i < ml->list->len; i++) {
     80    m = ml->list->pdata[i];
    7681    if (owl_message_is_delete(m)) {
    7782      owl_message_delete(m);
    7883    } else {
    79       owl_list_append_element(&newlist, m);
     84      g_ptr_array_add(newlist, m);
    8085    }
    8186  }
    8287
    8388  /* free the old list */
    84   owl_list_cleanup(&(ml->list), NULL);
     89  g_ptr_array_free(ml->list, true);
    8590
    8691  /* copy the new list to the old list */
     
    9297void owl_messagelist_invalidate_formats(const owl_messagelist *ml)
    9398{
    94   int i, j;
     99  int i;
    95100  owl_message *m;
    96101
    97   j=owl_list_get_size(&(ml->list));
    98   for (i=0; i<j; i++) {
    99     m=owl_list_get_element(&(ml->list), i);
     102  for (i = 0; i < ml->list->len; i++) {
     103    m = ml->list->pdata[i];
    100104    owl_message_invalidate_format(m);
    101105  }
  • owl.h

    r95b52d1 r2560529  
    199199#define OWL_ENABLE_ZCRYPT 1
    200200#endif
     201
     202/* Annotate functions in which the caller owns the return value and is
     203 * responsible for ensuring it is freed. */
     204#define CALLER_OWN G_GNUC_WARN_UNUSED_RESULT
    201205
    202206#define OWL_META(key) ((key)|010000)
     
    251255                                 * WARNING:  this approach is hard to make
    252256                                 * thread-safe... */
    253   char G_GNUC_WARN_UNUSED_RESULT *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
     257  CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    254258                                /* converts val to a string;
    255259                                 * caller must free the result */
     
    266270  GString *buff;
    267271} owl_fmtext;
    268 
    269 typedef struct _owl_list {
    270   int size;
    271   int avail;
    272   void **list;
    273 } owl_list;
    274272
    275273typedef struct _owl_dict_el {
     
    313311 
    314312  /* These don't take any context */
    315   char G_GNUC_WARN_UNUSED_RESULT *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
     313  CALLER_OWN char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
    316314                                /* takes argv and the full command as buff.
    317315                                 * caller must free return value if !NULL */
     
    320318
    321319  /* The following also take the active context if it's valid */
    322   char G_GNUC_WARN_UNUSED_RESULT *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
     320  CALLER_OWN char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
    323321                                /* takes argv and the full command as buff.
    324322                                 * caller must free return value if !NULL */
     
    338336  char *zsig;
    339337  char *message;
    340   owl_list recips;
     338  GPtrArray *recips;
    341339  int cc;
    342340  int noping;
     
    359357  int delete;
    360358  const char *hostname;
    361   owl_list attributes;            /* this is a list of pairs */
     359  GPtrArray *attributes;          /* this is a list of pairs */
    362360  char *timestr;
    363361  time_t time;
     
    418416
    419417typedef struct _owl_messagelist {
    420   owl_list list;
     418  GPtrArray *list;
    421419} owl_messagelist;
    422420
     
    481479  char     *name;               /* name of keymap */
    482480  char     *desc;               /* description */
    483   owl_list  bindings;           /* key bindings */
     481  GPtrArray *bindings;          /* key bindings */
    484482  const struct _owl_keymap *parent;     /* parent */
    485483  void (*default_fn)(owl_input j);      /* default action (takes a keypress) */
     
    504502
    505503typedef struct _owl_buddylist {
    506   owl_list buddies;
     504  GPtrArray *buddies;
    507505} owl_buddylist;
    508506
    509507typedef struct _owl_zbuddylist {
    510   owl_list zusers;
     508  GPtrArray *zusers;
    511509} owl_zbuddylist;
    512510
    513511typedef struct _owl_errqueue {
    514   owl_list errlist;
     512  GPtrArray *errlist;
    515513} owl_errqueue;
    516514
     
    538536  owl_dict filters;
    539537  GList *filterlist;
    540   owl_list puntlist;
     538  GPtrArray *puntlist;
    541539  owl_vardict vars;
    542540  owl_cmddict cmds;
  • perlconfig.c

    rd427f08 rce68f23  
    2323
    2424
    25 G_GNUC_WARN_UNUSED_RESULT SV *owl_new_sv(const char * str)
     25CALLER_OWN SV *owl_new_sv(const char * str)
    2626{
    2727  SV *ret = newSVpv(str, 0);
     
    3636}
    3737
    38 G_GNUC_WARN_UNUSED_RESULT AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))
     38CALLER_OWN AV *owl_new_av(const GPtrArray *l, SV *(*to_sv)(const void *))
    3939{
    4040  AV *ret;
     
    4444  ret = newAV();
    4545
    46   for (i = 0; i < owl_list_get_size(l); i++) {
    47     element = owl_list_get_element(l, i);
     46  for (i = 0; i < l->len; i++) {
     47    element = l->pdata[i];
    4848    av_push(ret, to_sv(element));
    4949  }
     
    5252}
    5353
    54 G_GNUC_WARN_UNUSED_RESULT HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
     54CALLER_OWN HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
    5555{
    5656  HV *ret;
    57   owl_list l;
     57  GPtrArray *keys;
    5858  const char *key;
    5959  void *element;
     
    6363
    6464  /* TODO: add an iterator-like interface to owl_dict */
    65   owl_list_create(&l);
    66   owl_dict_get_keys(d, &l);
    67   for (i = 0; i < owl_list_get_size(&l); i++) {
    68     key = owl_list_get_element(&l, i);
     65  keys = owl_dict_get_keys(d);
     66  for (i = 0; i < keys->len; i++) {
     67    key = keys->pdata[i];
    6968    element = owl_dict_find_element(d, key);
    7069    (void)hv_store(ret, key, strlen(key), to_sv(element), 0);
    7170  }
    72   owl_list_cleanup(&l, g_free);
     71  owl_ptr_array_free(keys, g_free);
    7372
    7473  return ret;
    7574}
    7675
    77 G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_message2hashref(const owl_message *m)
     76CALLER_OWN SV *owl_perlconfig_message2hashref(const owl_message *m)
    7877{
    7978  HV *h, *stash;
     
    115114  }
    116115
    117   j=owl_list_get_size(&(m->attributes));
    118   for(i=0; i<j; i++) {
    119     pair=owl_list_get_element(&(m->attributes), i);
     116  for (i = 0; i < m->attributes->len; i++) {
     117    pair = m->attributes->pdata[i];
    120118    (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
    121119                   owl_new_sv(owl_pair_get_value(pair)),0);
     
    165163}
    166164
    167 G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_curmessage2hashref(void)
     165CALLER_OWN SV *owl_perlconfig_curmessage2hashref(void)
    168166{
    169167  int curmsg;
     
    183181   This has been somewhat addressed, but is still not lossless.
    184182 */
    185 G_GNUC_WARN_UNUSED_RESULT owl_message *owl_perlconfig_hashref2message(SV *msg)
     183CALLER_OWN owl_message *owl_perlconfig_hashref2message(SV *msg)
    186184{
    187185  owl_message * m;
     
    251249/* Calls in a scalar context, passing it a hash reference.
    252250   If return value is non-null, caller must free. */
    253 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
     251CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    254252{
    255253  dSP ;
     
    300298   If the return value is non-null, the caller must free it.
    301299 */
    302 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
     300CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    303301{
    304302  dSP;
     
    350348
    351349/* caller must free result, if not NULL */
    352 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
     350CALLER_OWN char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
    353351{
    354352  int ret;
     
    436434
    437435/* caller is responsible for freeing returned string */
    438 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_execute(const char *line)
     436CALLER_OWN char *owl_perlconfig_execute(const char *line)
    439437{
    440438  STRLEN len;
     
    506504
    507505/* caller must free the result */
    508 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
     506CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    509507{
    510508  int i, count;
  • perlglue.xs

    rbcde7926 rce68f23  
    329329all_filters()
    330330        PREINIT:
    331                 owl_list fl;
    332         CODE:
    333         {
    334                 owl_list_create(&fl);
    335                 owl_dict_get_keys(&g.filters, &fl);
    336                 RETVAL = owl_new_av(&fl, (SV*(*)(const void*))owl_new_sv);
     331                GPtrArray *fl;
     332        CODE:
     333        {
     334                fl = owl_dict_get_keys(&g.filters);
     335                RETVAL = owl_new_av(fl, (SV*(*)(const void*))owl_new_sv);
    337336                sv_2mortal((SV*)RETVAL);
    338                 owl_list_cleanup(&fl, g_free);
     337                owl_ptr_array_free(fl, g_free);
    339338        }
    340339        OUTPUT:
     
    344343all_styles()
    345344        PREINIT:
    346                 owl_list l;
    347         CODE:
    348         {
    349                 owl_list_create(&l);
    350                 owl_global_get_style_names(&g, &l);
    351                 RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv);
     345                GPtrArray *l;
     346        CODE:
     347        {
     348                l = owl_global_get_style_names(&g);
     349                RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv);
    352350                sv_2mortal((SV*)RETVAL);
    353351        }
     
    355353                RETVAL
    356354        CLEANUP:
    357                 owl_list_cleanup(&l, g_free);
     355                owl_ptr_array_free(l, g_free);
    358356
    359357
     
    361359all_variables()
    362360        PREINIT:
    363                 owl_list l;
    364         CODE:
    365         {
    366                 owl_list_create(&l);
    367                 owl_dict_get_keys(owl_global_get_vardict(&g), &l);
    368                 RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv);
     361                GPtrArray *l;
     362        CODE:
     363        {
     364                l = owl_dict_get_keys(owl_global_get_vardict(&g));
     365                RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv);
    369366                sv_2mortal((SV*)RETVAL);
    370367        }
     
    372369                RETVAL
    373370        CLEANUP:
    374                 owl_list_cleanup(&l, g_free);
     371                owl_ptr_array_free(l, g_free);
    375372
    376373
     
    378375all_keymaps()
    379376        PREINIT:
    380                 owl_list l;
     377                GPtrArray *l;
    381378                const owl_keyhandler *kh;
    382379        CODE:
    383380        {
    384381                kh = owl_global_get_keyhandler(&g);
    385                 owl_list_create(&l);
    386                 owl_keyhandler_get_keymap_names(kh, &l);
    387                 RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv);
     382                l = owl_keyhandler_get_keymap_names(kh);
     383                RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv);
    388384                sv_2mortal((SV*)RETVAL);
    389385        }
     
    391387                RETVAL
    392388        CLEANUP:
    393                 owl_list_cleanup(&l, g_free);
     389                owl_ptr_array_free(l, g_free);
    394390
    395391void
  • popwin.c

    rd427f08 r6829afc  
    11#include "owl.h"
    22
    3 G_GNUC_WARN_UNUSED_RESULT owl_popwin *owl_popwin_new(void)
     3CALLER_OWN owl_popwin *owl_popwin_new(void)
    44{
    55  owl_popwin *pw = g_new0(owl_popwin, 1);
  • tester.c

    r4e37d56 rce68f23  
    230230int owl_dict_regtest(void) {
    231231  owl_dict d;
    232   owl_list l;
     232  GPtrArray *l;
    233233  int numfailed=0;
    234234  char *av = g_strdup("aval"), *bv = g_strdup("bval"), *cv = g_strdup("cval"),
     
    251251
    252252  FAIL_UNLESS("get_size", 3==owl_dict_get_size(&d));
    253   owl_list_create(&l);
    254   owl_dict_get_keys(&d, &l);
    255   FAIL_UNLESS("get_keys result size", 3==owl_list_get_size(&l));
     253  l = owl_dict_get_keys(&d);
     254  FAIL_UNLESS("get_keys result size", 3 == l->len);
    256255 
    257256  /* these assume the returned keys are sorted */
    258   FAIL_UNLESS("get_keys result val",0==strcmp("a",owl_list_get_element(&l,0)));
    259   FAIL_UNLESS("get_keys result val",0==strcmp("b",owl_list_get_element(&l,1)));
    260   FAIL_UNLESS("get_keys result val",0==strcmp("c",owl_list_get_element(&l,2)));
    261 
    262   owl_list_cleanup(&l, g_free);
     257  FAIL_UNLESS("get_keys result val", 0 == strcmp("a", l->pdata[0]));
     258  FAIL_UNLESS("get_keys result val", 0 == strcmp("b", l->pdata[1]));
     259  FAIL_UNLESS("get_keys result val", 0 == strcmp("c", l->pdata[2]));
     260
     261  owl_ptr_array_free(l, g_free);
    263262  owl_dict_cleanup(&d, NULL);
    264263
  • text.c

    rd427f08 r6829afc  
    77/* Returns a copy of 'in' with each line indented 'n'
    88 * characters. Result must be freed with g_free. */
    9 G_GNUC_WARN_UNUSED_RESULT char *owl_text_indent(const char *in, int n)
     9CALLER_OWN char *owl_text_indent(const char *in, int n)
    1010{
    1111  const char *ptr1, *ptr2, *last;
     
    4848
    4949/* caller must free the return */
    50 G_GNUC_WARN_UNUSED_RESULT char *owl_text_htmlstrip(const char *in)
     50CALLER_OWN char *owl_text_htmlstrip(const char *in)
    5151{
    5252  const char *ptr1, *end, *ptr2, *ptr3;
     
    129129
    130130/* Caller must free return */
    131 G_GNUC_WARN_UNUSED_RESULT char *owl_text_expand_tabs(const char *in)
     131CALLER_OWN char *owl_text_expand_tabs(const char *in)
    132132{
    133133  int len = 0;
     
    188188
    189189/* caller must free the return */
    190 G_GNUC_WARN_UNUSED_RESULT char *owl_text_wordwrap(const char *in, int col)
     190CALLER_OWN char *owl_text_wordwrap(const char *in, int col)
    191191{
    192192  char *out;
     
    269269 * Caller must free returned string.
    270270 */
    271 G_GNUC_WARN_UNUSED_RESULT char *owl_text_substitute(const char *in, const char *from, const char *to)
     271CALLER_OWN char *owl_text_substitute(const char *in, const char *from, const char *to)
    272272{
    273273  char **split = g_strsplit(in, from, 0), *out;
     
    284284 * On success returns the string, on error returns NULL.
    285285 */
    286 G_GNUC_WARN_UNUSED_RESULT char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
     286CALLER_OWN char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
    287287{
    288288  int i, x, r, place, escape;
  • util.c

    rd427f08 r3cdd6d2  
    3535 * duplicate slashes are removed.  Caller must free the return.
    3636 */
    37 G_GNUC_WARN_UNUSED_RESULT char *owl_util_makepath(const char *in)
     37CALLER_OWN char *owl_util_makepath(const char *in)
    3838{
    3939  int i, j, x;
     
    9898}
    9999
     100void owl_ptr_array_free(GPtrArray *array, GDestroyNotify element_free_func)
     101{
     102  /* TODO: when we move to requiring glib 2.22+, use
     103   * g_ptr_array_new_with_free_func instead. */
     104  if (element_free_func)
     105    g_ptr_array_foreach(array, (GFunc)element_free_func, NULL);
     106  g_ptr_array_free(array, true);
     107}
     108
    100109/* Break a command line up into argv, argc.  The caller must free
    101110   the returned values with g_strfreev.  If there is an error argc will be set
    102111   to -1, argv will be NULL and the caller does not need to free anything. The
    103112   returned vector is NULL-terminated. */
    104 G_GNUC_WARN_UNUSED_RESULT char **owl_parseline(const char *line, int *argc)
     113CALLER_OWN char **owl_parseline(const char *line, int *argc)
    105114{
    106115  GPtrArray *argv;
     
    170179  /* check for unbalanced quotes */
    171180  if (quote!='\0') {
    172     /* TODO: when we move to requiring glib 2.22+, use
    173      * g_ptr_array_new_with_free_func. */
    174     g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
    175     g_ptr_array_free(argv, true);
     181    owl_ptr_array_free(argv, g_free);
    176182    if (argc) *argc = -1;
    177183    return(NULL);
     
    245251}
    246252
    247 G_GNUC_WARN_UNUSED_RESULT char *owl_string_build_quoted(const char *tmpl, ...)
     253CALLER_OWN char *owl_string_build_quoted(const char *tmpl, ...)
    248254{
    249255  GString *buf = g_string_new("");
     
    257263/* Returns a quoted version of arg suitable for placing in a
    258264 * command-line. Result should be freed with g_free. */
    259 G_GNUC_WARN_UNUSED_RESULT char *owl_arg_quote(const char *arg)
     265CALLER_OWN char *owl_arg_quote(const char *arg)
    260266{
    261267  GString *buf = g_string_new("");;
     
    265271
    266272/* caller must free the return */
    267 G_GNUC_WARN_UNUSED_RESULT char *owl_util_minutes_to_timestr(int in)
     273CALLER_OWN char *owl_util_minutes_to_timestr(int in)
    268274{
    269275  int days, hours;
     
    331337
    332338/* Get the default tty name.  Caller must free the return */
    333 G_GNUC_WARN_UNUSED_RESULT char *owl_util_get_default_tty(void)
     339CALLER_OWN char *owl_util_get_default_tty(void)
    334340{
    335341  const char *tmp;
     
    353359 * return.
    354360 */
    355 G_GNUC_WARN_UNUSED_RESULT char *owl_util_stripnewlines(const char *in)
     361CALLER_OWN char *owl_util_stripnewlines(const char *in)
    356362{
    357363 
     
    384390 * Error conditions are the same as g_file_read_link.
    385391 */
    386 G_GNUC_WARN_UNUSED_RESULT gchar *owl_util_recursive_resolve_link(const char *filename)
     392CALLER_OWN gchar *owl_util_recursive_resolve_link(const char *filename)
    387393{
    388394  gchar *last_path = g_strdup(filename);
     
    511517   The caller is responsible for freeing the allocated string.
    512518*/
    513 G_GNUC_WARN_UNUSED_RESULT char *owl_util_baseclass(const char *class)
     519CALLER_OWN char *owl_util_baseclass(const char *class)
    514520{
    515521  char *start, *end;
     
    547553/* Strips format characters from a valid utf-8 string. Returns the
    548554   empty string if 'in' does not validate.  Caller must free the return. */
    549 G_GNUC_WARN_UNUSED_RESULT char *owl_strip_format_chars(const char *in)
     555CALLER_OWN char *owl_strip_format_chars(const char *in)
    550556{
    551557  char *r;
     
    586592 * Caller must free the return.
    587593 */
    588 G_GNUC_WARN_UNUSED_RESULT char *owl_validate_or_convert(const char *in)
     594CALLER_OWN char *owl_validate_or_convert(const char *in)
    589595{
    590596  if (g_utf8_validate(in, -1, NULL)) {
     
    602608 * Caller must free the return.
    603609 */
    604 G_GNUC_WARN_UNUSED_RESULT char *owl_validate_utf8(const char *in)
     610CALLER_OWN char *owl_validate_utf8(const char *in)
    605611{
    606612  char *out;
     
    635641
    636642/* caller must free the return */
    637 G_GNUC_WARN_UNUSED_RESULT char *owl_escape_highbit(const char *str)
     643CALLER_OWN char *owl_escape_highbit(const char *str)
    638644{
    639645  GString *out = g_string_new("");
     
    698704
    699705/* Read the rest of the input available in fp into a string. */
    700 G_GNUC_WARN_UNUSED_RESULT char *owl_slurp(FILE *fp)
     706CALLER_OWN char *owl_slurp(FILE *fp)
    701707{
    702708  char *buf = NULL;
  • variable.c

    rd427f08 rce68f23  
    646646}
    647647
    648 G_GNUC_WARN_UNUSED_RESULT owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
     648CALLER_OWN owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
    649649{
    650650  owl_variable * var = g_new0(owl_variable, 1);
     
    729729}
    730730
    731 void owl_variable_dict_get_names(const owl_vardict *d, owl_list *l) {
    732   owl_dict_get_keys(d, l);
     731CALLER_OWN GPtrArray *owl_variable_dict_get_names(const owl_vardict *d) {
     732  return owl_dict_get_keys(d);
    733733}
    734734
     
    825825}
    826826
    827 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
     827CALLER_OWN char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
    828828{
    829829  owl_variable *v;
     
    834834}
    835835
    836 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
     836CALLER_OWN char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
    837837{
    838838  owl_variable *v;
     
    995995}
    996996
    997 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
     997CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
    998998{
    999999  if (val == NULL) {
     
    10311031}
    10321032
    1033 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
     1033CALLER_OWN char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
    10341034{
    10351035  if (val == NULL) {
     
    10711071}
    10721072
    1073 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
     1073CALLER_OWN char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
    10741074{
    10751075  char **enums;
     
    11121112}
    11131113
    1114 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
     1114CALLER_OWN char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
    11151115{
    11161116  if (val == NULL) {
  • view.c

    r3b8a563 rfc8a87a  
    3737  ml=&(v->ml);
    3838
    39   /* nuke the old list */
    40   owl_list_cleanup(&ml->list, NULL);
     39  /* nuke the old list, don't free the messages */
     40  owl_messagelist_cleanup(ml, false);
    4141  owl_messagelist_create(&(v->ml));
    4242
     
    159159void owl_view_cleanup(owl_view *v)
    160160{
    161   owl_list_cleanup(&v->ml.list, NULL);
     161  owl_messagelist_cleanup(&v->ml, false);
    162162  g_free(v->name);
    163163}
  • viewwin.c

    rd427f08 r6829afc  
    1212 * will be used by the viewwin
    1313 */
    14 G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
     14CALLER_OWN owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1515{
    1616  owl_viewwin *v = g_new0(owl_viewwin, 1);
     
    3434 * will be used by the viewwin
    3535 */
    36 G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
     36CALLER_OWN owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
    3737{
    3838  char *text;
     
    237237}
    238238
    239 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
     239CALLER_OWN owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
    240240  int lines, cols;
    241241  owl_editwin *cmdline;
  • window.c

    rd427f08 r6829afc  
    569569};
    570570
    571 G_GNUC_WARN_UNUSED_RESULT GSource *owl_window_redraw_source_new(void)
     571CALLER_OWN GSource *owl_window_redraw_source_new(void)
    572572{
    573573  GSource *source;
  • zbuddylist.c

    rddbbcffa r7ed9bc6  
    33void owl_zbuddylist_create(owl_zbuddylist *zb)
    44{
    5   owl_list_create(&(zb->zusers));
     5  zb->zusers = g_ptr_array_new();
    66}
    77
    88int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name)
    99{
    10   int i, j;
     10  int i;
    1111  char *user;
    1212
    1313  user=long_zuser(name);
    1414
    15   j=owl_list_get_size(&(zb->zusers));
    16   for (i=0; i<j; i++) {
    17     if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) {
     15  for (i = 0; i < zb->zusers->len; i++) {
     16    if (!strcasecmp(user, zb->zusers->pdata[i])) {
    1817      g_free(user);
    1918      return(-1);
    2019    }
    2120  }
    22   owl_list_append_element(&(zb->zusers), user);
     21  g_ptr_array_add(zb->zusers, user);
    2322  return(0);
    2423}
     
    2625int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name)
    2726{
    28   int i, j;
    29   char *user, *ptr;
     27  int i;
     28  char *user;
    3029
    3130  user=long_zuser(name);
    3231
    33   j=owl_list_get_size(&(zb->zusers));
    34   for (i=0; i<j; i++) {
    35     ptr=owl_list_get_element(&(zb->zusers), i);
    36     if (!strcasecmp(user, ptr)) {
    37       owl_list_remove_element(&(zb->zusers), i);
    38       g_free(ptr);
     32  for (i = 0; i < zb->zusers->len; i++) {
     33    if (!strcasecmp(user, zb->zusers->pdata[i])) {
     34      g_free(g_ptr_array_remove_index(zb->zusers, i));
    3935      g_free(user);
    4036      return(0);
     
    4743int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name)
    4844{
    49   int i, j;
     45  int i;
    5046  char *user;
    5147
    5248  user=long_zuser(name);
    5349
    54   j=owl_list_get_size(&(zb->zusers));
    55   for (i=0; i<j; i++) {
    56     if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) {
     50  for (i = 0; i < zb->zusers->len; i++) {
     51    if (!strcasecmp(user, zb->zusers->pdata[i])) {
    5752      g_free(user);
    5853      return(1);
  • zcrypt.c

    rd427f08 r6829afc  
    2727#include "filterproc.h"
    2828
     29/* Annotate functions in which the caller owns the return value and is
     30 * responsible for ensuring it is freed. */
     31#define CALLER_OWN G_GNUC_WARN_UNUSED_RESULT
     32
    2933#define MAX_KEY      128
    3034#define MAX_LINE     128
     
    5357} ZWRITEOPTIONS;
    5458
    55 G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
     59CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
    5660int ParseCryptSpec(const char *spec, const char **keyfile);
    57 G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end);
    58 G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile);
     61CALLER_OWN char *BuildArgString(char **argv, int start, int end);
     62CALLER_OWN char *read_keystring(const char *keyfile);
    5963
    6064int do_encrypt(int zephyr, const char *class, const char *instance,
     
    364368/* Build a space-separated string from argv from elements between start  *
    365369 * and end - 1.  malloc()'s the returned string. */
    366 G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end)
     370CALLER_OWN char *BuildArgString(char **argv, int start, int end)
    367371{
    368372  int len = 1;
     
    401405#define MAX_SEARCH 3
    402406/* Find the class/instance in the .crypt-table */
    403 G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
     407CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
    404408{
    405409  char *keyfile = NULL;
     
    579583}
    580584
    581 G_GNUC_WARN_UNUSED_RESULT char *slurp_stdin(int ignoredot, int *length) {
     585CALLER_OWN char *slurp_stdin(int ignoredot, int *length) {
    582586  char *buf;
    583587  char *inptr;
     
    611615}
    612616
    613 G_GNUC_WARN_UNUSED_RESULT char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
     617CALLER_OWN char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
    614618  char *buf;
    615619
     
    637641}
    638642
    639 G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile) {
     643CALLER_OWN char *read_keystring(const char *keyfile) {
    640644  char *keystring;
    641645  FILE *fkey = fopen(keyfile, "r");
  • zephyr.c

    rd427f08 recffae6  
    524524 */
    525525#ifdef HAVE_LIBZEPHYR
    526 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(const ZNotice_t *n, int j)
     526CALLER_OWN char *owl_zephyr_get_field(const ZNotice_t *n, int j)
    527527{
    528528  int i, count, save;
     
    552552}
    553553
    554 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
     554CALLER_OWN char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
    555555{
    556556  int i, count, save;
     
    584584}
    585585#else
    586 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(void *n, int j)
     586CALLER_OWN char *owl_zephyr_get_field(void *n, int j)
    587587{
    588588  return(g_strdup(""));
    589589}
    590 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(void *n, int j)
     590CALLER_OWN char *owl_zephyr_get_field_as_utf8(void *n, int j)
    591591{
    592592  return owl_zephyr_get_field(n, j);
     
    621621 * caller must free the return
    622622 */
    623 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
     623CALLER_OWN char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
    624624{
    625625#define OWL_NFIELDS     5
     
    838838      zw.opcode = g_strdup(retnotice->z_opcode);
    839839      zw.zsig   = g_strdup("");
    840       owl_list_create(&(zw.recips));
    841       owl_list_append_element(&(zw.recips), g_strdup(retnotice->z_recipient));
     840      zw.recips = g_ptr_array_new();
     841      g_ptr_array_add(zw.recips, g_strdup(retnotice->z_recipient));
    842842
    843843      owl_log_outgoing_zephyr_error(&zw, buff);
     
    942942#endif
    943943
    944 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_zlocate(const char *user, int auth)
     944CALLER_OWN char *owl_zephyr_zlocate(const char *user, int auth)
    945945{
    946946#ifdef HAVE_LIBZEPHYR
     
    10421042
    10431043/* caller must free the return */
    1044 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
     1044CALLER_OWN char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
    10451045{
    10461046  return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
     
    11221122 * free the return.
    11231123 */
    1124 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_getsubs(void)
     1124CALLER_OWN char *owl_zephyr_getsubs(void)
    11251125{
    11261126#ifdef HAVE_LIBZEPHYR
     
    12421242 * The caller must free the return
    12431243 */
    1244 G_GNUC_WARN_UNUSED_RESULT char *short_zuser(const char *in)
     1244CALLER_OWN char *short_zuser(const char *in)
    12451245{
    12461246  char *ptr = strrchr(in, '@');
     
    12541254 * The caller must free the return.
    12551255 */
    1256 G_GNUC_WARN_UNUSED_RESULT char *long_zuser(const char *in)
     1256CALLER_OWN char *long_zuser(const char *in)
    12571257{
    12581258  char *ptr = strrchr(in, '@');
     
    12821282 * caller must free the return.
    12831283 */
    1284 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_smartstripped_user(const char *in)
     1284CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in)
    12851285{
    12861286  char *slash, *dot, *realm, *out;
     
    13241324}
    13251325
    1326 /* read the list of users in 'filename' as a .anyone file, and put the
    1327  * names of the zephyr users in the list 'in'.  If 'filename' is NULL,
    1328  * use the default .anyone file in the users home directory.  Returns
    1329  * -1 on failure, 0 on success.
     1326/* Read the list of users in 'filename' as a .anyone file, and return as a
     1327 * GPtrArray of strings.  If 'filename' is NULL, use the default .anyone file
     1328 * in the users home directory.  Returns NULL on failure.
    13301329 */
    1331 int owl_zephyr_get_anyone_list(owl_list *in, const char *filename)
     1330GPtrArray *owl_zephyr_get_anyone_list(const char *filename)
    13321331{
    13331332#ifdef HAVE_LIBZEPHYR
    13341333  char *ourfile, *tmp, *s = NULL;
    13351334  FILE *f;
     1335  GPtrArray *list;
    13361336
    13371337  ourfile = owl_zephyr_dotfile(".anyone", filename);
     
    13411341    owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : "");
    13421342    g_free(ourfile);
    1343     return -1;
     1343    return NULL;
    13441344  }
    13451345  g_free(ourfile);
    13461346
     1347  list = g_ptr_array_new();
    13471348  while (owl_getline_chomp(&s, f)) {
    13481349    /* ignore comments, blank lines etc. */
     
    13601361      tmp[0] = '\0';
    13611362
    1362     owl_list_append_element(in, long_zuser(s));
     1363    g_ptr_array_add(list, long_zuser(s));
    13631364  }
    13641365  g_free(s);
    13651366  fclose(f);
    1366   return 0;
    1367 #else
    1368   return -1;
     1367  return list;
     1368#else
     1369  return NULL;
    13691370#endif
    13701371}
  • zwrite.c

    rd427f08 r3cdd6d2  
    55#include "owl.h"
    66
    7 G_GNUC_WARN_UNUSED_RESULT owl_zwrite *owl_zwrite_new(const char *line)
     7CALLER_OWN owl_zwrite *owl_zwrite_new(const char *line)
    88{
    99  owl_zwrite *z = g_new(owl_zwrite, 1);
     
    3434  z->cc=0;
    3535  z->noping=0;
    36   owl_list_create(&(z->recips));
     36  z->recips = g_ptr_array_new();
    3737  z->zwriteline = g_strdup(line);
    3838
     
    9797      }
    9898      /* we must already have users or a class or an instance */
    99       if (owl_list_get_size(&(z->recips))<1 && (!z->class) && (!z->inst)) {
     99      if (z->recips->len < 1 && (!z->class) && (!z->inst)) {
    100100        badargs=1;
    101101        break;
     
    117117    } else {
    118118      /* anything unattached is a recipient */
    119       owl_list_append_element(&(z->recips), owl_validate_utf8(myargv[0]));
     119      g_ptr_array_add(z->recips, owl_validate_utf8(myargv[0]));
    120120      myargv++;
    121121      myargc--;
     
    131131  if (z->class == NULL &&
    132132      z->inst == NULL &&
    133       owl_list_get_size(&(z->recips))==0) {
     133      z->recips->len == 0) {
    134134    owl_function_error("You must specify a recipient for zwrite");
    135135    return(-1);
     
    162162void owl_zwrite_send_ping(const owl_zwrite *z)
    163163{
    164   int i, j;
     164  int i;
    165165  char *to;
    166166
     
    173173  /* if there are no recipients we won't send a ping, which
    174174     is what we want */
    175   j=owl_list_get_size(&(z->recips));
    176   for (i=0; i<j; i++) {
     175  for (i = 0; i < z->recips->len; i++) {
    177176    to = owl_zwrite_get_recip_n_with_realm(z, i);
    178177    send_ping(to, z->class, z->inst);
     
    191190void owl_zwrite_set_message(owl_zwrite *z, const char *msg)
    192191{
    193   int i, j;
     192  int i;
    194193  GString *message;
    195194  char *tmp = NULL, *tmp2;
     
    197196  g_free(z->message);
    198197
    199   j=owl_list_get_size(&(z->recips));
    200   if (j>0 && z->cc) {
     198  if (z->recips->len > 0 && z->cc) {
    201199    message = g_string_new("CC: ");
    202     for (i=0; i<j; i++) {
     200    for (i = 0; i < z->recips->len; i++) {
    203201      tmp = owl_zwrite_get_recip_n_with_realm(z, i);
    204202      g_string_append_printf(message, "%s ", tmp);
     
    233231int owl_zwrite_send_message(const owl_zwrite *z)
    234232{
    235   int i, j, ret = 0;
     233  int i, ret = 0;
    236234  char *to = NULL;
    237235
    238236  if (z->message==NULL) return(-1);
    239237
    240   j=owl_list_get_size(&(z->recips));
    241   if (j>0) {
    242     for (i=0; i<j; i++) {
     238  if (z->recips->len > 0) {
     239    for (i = 0; i < z->recips->len; i++) {
    243240      to = owl_zwrite_get_recip_n_with_realm(z, i);
    244241      ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
     
    312309int owl_zwrite_get_numrecips(const owl_zwrite *z)
    313310{
    314   return(owl_list_get_size(&(z->recips)));
     311  return z->recips->len;
    315312}
    316313
    317314const char *owl_zwrite_get_recip_n(const owl_zwrite *z, int n)
    318315{
    319   return(owl_list_get_element(&(z->recips), n));
     316  return z->recips->pdata[n];
    320317}
    321318
    322319/* Caller must free the result. */
    323 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
     320CALLER_OWN char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
    324321{
    325322  if (z->realm[0]) {
     
    333330{
    334331  /* return true if at least one of the recipients is personal */
    335   int i, j;
    336   char *foo;
    337 
    338   j=owl_list_get_size(&(z->recips));
    339   for (i=0; i<j; i++) {
    340     foo=owl_list_get_element(&(z->recips), i);
    341     if (foo[0]!='@') return(1);
     332  int i;
     333  char *recip;
     334
     335  for (i = 0; i < z->recips->len; i++) {
     336    recip = z->recips->pdata[i];
     337    if (recip[0] != '@') return 1;
    342338  }
    343339  return(0);
     
    352348void owl_zwrite_cleanup(owl_zwrite *z)
    353349{
    354   owl_list_cleanup(&(z->recips), &g_free);
     350  owl_ptr_array_free(z->recips, g_free);
    355351  g_free(z->cmd);
    356352  g_free(z->zwriteline);
     
    370366 * If not a CC, only the recip_index'th user will be replied to.
    371367 */
    372 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
     368CALLER_OWN char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
    373369{
    374370  /* Match ordering in zwrite help. */
     
    403399  }
    404400  if (z->cc) {
    405     for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {
     401    for (i = 0; i < z->recips->len; i++) {
    406402      g_string_append_c(buf, ' ');
    407       owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i));
     403      owl_string_append_quoted_arg(buf, z->recips->pdata[i]);
    408404    }
    409   } else if (recip_index < owl_list_get_size(&(z->recips))) {
     405  } else if (recip_index < z->recips->len) {
    410406    g_string_append_c(buf, ' ');
    411     owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), recip_index));
     407    owl_string_append_quoted_arg(buf, z->recips->pdata[recip_index]);
    412408  }
    413409
Note: See TracChangeset for help on using the changeset viewer.