Changes in / [d8e2f07:95b52d1]


Ignore:
Files:
1 added
36 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    rc266281 r4f746f8  
    3838           $(GIT_FLAGS)
    3939
    40 CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \
     40CODELIST_SRCS=list.c 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

    re4524da rd427f08  
    437437
    438438/* caller must free the return */
    439 CALLER_OWN char *owl_aim_normalize_screenname(const char *in)
     439G_GNUC_WARN_UNUSED_RESULT char *owl_aim_normalize_screenname(const char *in)
    440440{
    441441  char *out;
     
    14391439  const char *address, *SNs;
    14401440  int num, i;
    1441   GPtrArray *list;
     1441  owl_list list;
    14421442 
    14431443  va_start(ap, fr);
     
    14471447  va_end(ap);
    14481448
    1449   list = g_ptr_array_new();
     1449  owl_list_create(&list);
    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     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;
     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);
    14591459}
    14601460
  • buddylist.c

    r3cdd6d2 r96828e4  
    33void owl_buddylist_init(owl_buddylist *bl)
    44{
    5   bl->buddies = g_ptr_array_new();
     5  owl_list_create(&(bl->buddies));
    66}
    77
     
    1414 
    1515  owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname);
    16   g_ptr_array_add(bl->buddies, b);
     16  owl_list_append_element(&(bl->buddies), b);
    1717}
    1818
     
    2121int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, const char *name)
    2222{
    23   int i;
     23  int i, j;
    2424  owl_buddy *b;
    2525
    26   for (i = 0; i < bl->buddies->len; i++) {
    27     b = bl->buddies->pdata[i];
     26  j=owl_list_get_size(&(bl->buddies));
     27  for (i=0; i<j; i++) {
     28    b=owl_list_get_element(&(bl->buddies), i);
    2829    if (!strcasecmp(name, owl_buddy_get_name(b)) && owl_buddy_is_proto_aim(b)) {
    29       owl_buddy_delete(g_ptr_array_remove_index(bl->buddies, i));
     30      owl_list_remove_element(&(bl->buddies), i);
     31      owl_buddy_delete(b);
    3032      return(0);
    3133    }
     
    8587int owl_buddylist_get_size(const owl_buddylist *bl)
    8688{
    87   return bl->buddies->len;
     89  return(owl_list_get_size(&(bl->buddies)));
    8890}
    8991
     
    9597  if (index>(owl_buddylist_get_size(bl)-1)) return(NULL);
    9698
    97   return bl->buddies->pdata[index];
     99  return(owl_list_get_element(&(bl->buddies), index));
    98100}
    99101
     
    103105owl_buddy *owl_buddylist_get_aim_buddy(const owl_buddylist *bl, const char *name)
    104106{
    105   int i;
     107  int i, j;
    106108  owl_buddy *b;
    107109
    108   for (i = 0; i < bl->buddies->len; i++) {
    109     b = bl->buddies->pdata[i];
     110  j=owl_list_get_size(&(bl->buddies));
     111  for (i=0; i<j; i++) {
     112    b=owl_list_get_element(&(bl->buddies), i);
    110113    if (!strcasecmp(name, owl_buddy_get_name(b))) return(b);
    111114  }
     
    128131void owl_buddylist_clear(owl_buddylist *bl)
    129132{
    130   g_ptr_array_foreach(bl->buddies, (GFunc)owl_buddy_delete, NULL);
    131   g_ptr_array_set_size(bl->buddies, 0);
     133  owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);
     134  owl_list_create(&(bl->buddies));
    132135}
    133136
    134137void owl_buddylist_cleanup(owl_buddylist *bl)
    135138{
    136   owl_ptr_array_free(bl->buddies, (GDestroyNotify)owl_buddy_delete);
     139  owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);
    137140}
  • cmd.c

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

    re6d7e4e rb470451  
    13731373}
    13741374
    1375 CALLER_OWN char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
     1375G_GNUC_WARN_UNUSED_RESULT char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
    13761376{
    13771377  char *filtname = NULL;
     
    14131413}
    14141414
    1415 CALLER_OWN char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
     1415G_GNUC_WARN_UNUSED_RESULT char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
    14161416{
    14171417  if(argc != 1)
     
    16441644
    16451645
    1646 CALLER_OWN char *owl_command_exec(int argc, const char *const *argv, const char *buff)
     1646G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
     1651G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
     1656G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_command_perl(int argc, const char *const *argv, const char *buff)
     1661G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
     1666G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
     1671G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_command_multi(int argc, const char *const *argv, const char *buff)
     1676G_GNUC_WARN_UNUSED_RESULT 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   GPtrArray * fl;
     2469  owl_list * fl;
     2470  owl_filter * f;
    24702471  int i;
    24712472
     
    24772478    if(unpunt && (i=atoi(argv[1])) !=0) {
    24782479      i--;      /* Accept 1-based indexing */
    2479       if (i < fl->len) {
    2480         owl_filter_delete(g_ptr_array_remove_index(fl, i));
     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);
    24812484        return;
    24822485      } else {
     
    25912594}
    25922595
    2593 CALLER_OWN char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
     2596G_GNUC_WARN_UNUSED_RESULT char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
    25942597{
    25952598  const char *stylename;
     
    26342637}
    26352638
    2636 CALLER_OWN char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
     2639G_GNUC_WARN_UNUSED_RESULT char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
    26372640{
    26382641  owl_history *hist;
  • context.c

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

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

    r6829afc rd427f08  
    88}
    99
    10 CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
     10G_GNUC_WARN_UNUSED_RESULT 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

    r6829afc rd427f08  
    6161static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len);
    6262static int oe_copy_region(owl_editwin *e);
    63 static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end);
     63static G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN owl_editwin *owl_editwin_allocate(void)
     72static G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_allocate(void)
    7373{
    7474  owl_editwin *e = g_new0(owl_editwin, 1);
     
    142142}
    143143
    144 CALLER_OWN owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
     144G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_editwin_get_region(owl_editwin *e)
     1371G_GNUC_WARN_UNUSED_RESULT char *owl_editwin_get_region(owl_editwin *e)
    13721372{
    13731373  int start, end;
     
    13881388}
    13891389
    1390 static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end)
     1390static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end)
    13911391{
    13921392  char *p;
  • errqueue.c

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

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

    r2560529 rd427f08  
    171171 * freeing the return
    172172 */
    173 CALLER_OWN char *owl_fmtext_print_plain(const owl_fmtext *f)
     173char G_GNUC_WARN_UNUSED_RESULT *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 GPtrArray *l, const char *join_with, char *(format_fn)(const char *))
    758 {
    759   int i;
     757void 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;
    760760  const char *elem;
    761761  char *text;
    762762
    763   for (i = 0; i < l->len; i++) {
    764     elem = l->pdata[i];
     763  size = owl_list_get_size(l);
     764  for (i=0; i<size; i++) {
     765    elem = owl_list_get_element(l,i);
    765766    if (elem && format_fn) {
    766767      text = format_fn(elem);
     
    772773      owl_fmtext_append_normal(f, elem);
    773774    }
    774     if ((i < l->len - 1) && join_with) {
     775    if ((i < size-1) && join_with) {
    775776      owl_fmtext_append_normal(f, join_with);
    776777    }
  • functions.c

    rce68f23 rb470451  
    1414#include "filterproc.h"
    1515
    16 CALLER_OWN char *owl_function_command(const char *cmdbuff)
     16G_GNUC_WARN_UNUSED_RESULT char *owl_function_command(const char *cmdbuff)
    1717{
    1818  owl_function_debugmsg("executing command: %s", cmdbuff);
     
    2121}
    2222
    23 CALLER_OWN char *owl_function_command_argv(const char *const *argv, int argc)
     23G_GNUC_WARN_UNUSED_RESULT 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   GPtrArray *l;
     49  owl_list 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   l = owl_cmddict_get_names(owl_global_get_cmddict(&g));
    56   owl_fmtext_append_list(&fm, l, "\n", owl_function_cmd_describe);
     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);
    5758  owl_fmtext_append_normal(&fm, "\n");
    5859  owl_function_popless_fmtext(&fm);
    59   owl_ptr_array_free(l, g_free);
     60  owl_list_cleanup(&l, g_free);
    6061  owl_fmtext_cleanup(&fm);
    6162}
     
    8081
    8182void owl_function_show_styles(void) {
    82   GPtrArray *l;
     83  owl_list l;
    8384  owl_fmtext fm;
    8485
    8586  owl_fmtext_init_null(&fm);
    8687  owl_fmtext_append_bold(&fm, "Styles:\n");
    87   l = owl_global_get_style_names(&g);
    88   owl_fmtext_append_list(&fm, l, "\n", owl_function_style_describe);
     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);
    8991  owl_fmtext_append_normal(&fm, "\n");
    9092  owl_function_popless_fmtext(&fm);
    91   owl_ptr_array_free(l, g_free);
     93  owl_list_cleanup(&l, g_free);
    9294  owl_fmtext_cleanup(&fm);
    9395}
    9496
    95 CALLER_OWN char *owl_function_style_describe(const char *name)
     97G_GNUC_WARN_UNUSED_RESULT char *owl_function_style_describe(const char *name)
    9698{
    9799  const char *desc;
     
    110112}
    111113
    112 CALLER_OWN char *owl_function_cmd_describe(const char *name)
     114G_GNUC_WARN_UNUSED_RESULT char *owl_function_cmd_describe(const char *name)
    113115{
    114116  const owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    248250 * owl_global_messagequeue_addmsg() for that.
    249251 */
    250 CALLER_OWN owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
     252G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
    251253{
    252254  owl_message *m;
     
    269271 * owl_global_messagequeue_addmsg() for that.
    270272 */
    271 CALLER_OWN owl_message *owl_function_make_outgoing_loopback(const char *body)
     273G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_loopback(const char *body)
    272274{
    273275  owl_message *m;
     
    15741576  const char *name;
    15751577  char *var;
    1576   GPtrArray *varnames;
    1577   int i;
     1578  owl_list varnames;
     1579  int i, numvarnames;
    15781580  GString *str   = g_string_new("");
    15791581
    15801582  g_string_append_printf(str, "%-20s = %s\n", "VARIABLE", "VALUE");
    15811583  g_string_append_printf(str, "%-20s   %s\n",  "--------", "-----");
    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];
     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);
    15851589    if (name && name[0]!='_') {
    15861590      g_string_append_printf(str, "\n%-20s = ", name);
     
    15931597  }
    15941598  g_string_append(str, "\n");
    1595   owl_ptr_array_free(varnames, g_free);
     1599  owl_list_cleanup(&varnames, g_free);
    15961600
    15971601  owl_function_popless_text(str->str);
     
    16011605void owl_function_show_variables(void)
    16021606{
    1603   GPtrArray *varnames;
     1607  owl_list varnames;
    16041608  owl_fmtext fm; 
    1605   int i;
     1609  int i, numvarnames;
    16061610  const char *varname;
    16071611
     
    16091613  owl_fmtext_append_bold(&fm,
    16101614      "Variables: (use 'show variable <name>' for details)\n");
    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];
     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);
    16141620    if (varname && varname[0]!='_') {
    16151621      owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    16161622    }
    16171623  }
    1618   owl_ptr_array_free(varnames, g_free);
     1624  owl_list_cleanup(&varnames, g_free);
    16191625  owl_function_popless_fmtext(&fm);
    16201626  owl_fmtext_cleanup(&fm);
     
    18941900}
    18951901
    1896 CALLER_OWN owl_editwin *owl_function_start_question(const char *line)
     1902G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_question(const char *line)
    18971903{
    18981904  owl_editwin *tw;
     
    19091915}
    19101916
    1911 CALLER_OWN owl_editwin *owl_function_start_password(const char *line)
     1917G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_password(const char *line)
    19121918{
    19131919  owl_editwin *tw;
     
    19261932}
    19271933
    1928 CALLER_OWN char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
     1934G_GNUC_WARN_UNUSED_RESULT char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
    19291935{
    19301936  /* if type == 1 display in a popup
     
    19691975}
    19701976
    1971 CALLER_OWN char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
     1977G_GNUC_WARN_UNUSED_RESULT char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
    19721978{
    19731979  /* if type == 1 display in a popup
     
    21392145 * Returns the name of the negated filter, which the caller must free.
    21402146 */
    2141 CALLER_OWN char *owl_function_create_negative_filter(const char *filtername)
     2147G_GNUC_WARN_UNUSED_RESULT char *owl_function_create_negative_filter(const char *filtername)
    21422148{
    21432149  char *newname;
     
    22092215{
    22102216  const owl_filter *f;
    2211   const GPtrArray *fl;
     2217  const owl_list *fl;
    22122218  char *tmp;
    22132219  owl_fmtext fm;
    2214   int i;
     2220  int i, j;
    22152221
    22162222  owl_fmtext_init_null(&fm);
    22172223
    22182224  fl=owl_global_get_puntlist(&g);
     2225  j=owl_list_get_size(fl);
    22192226  owl_fmtext_append_bold(&fm, "Active zpunt filters:\n");
    22202227
    2221   for (i = 0; i < fl->len; i++) {
    2222     f = fl->pdata[i];
     2228  for (i=0; i<j; i++) {
     2229    f=owl_list_get_element(fl, i);
    22232230    owl_fmtext_appendf_normal(&fm, "[% 2d] ", i+1);
    22242231    tmp = owl_filter_print(f);
     
    22352242 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22362243 */
    2237 CALLER_OWN char *owl_function_classinstfilt(const char *c, const char *i, int related)
     2244G_GNUC_WARN_UNUSED_RESULT char *owl_function_classinstfilt(const char *c, const char *i, int related)
    22382245{
    22392246  owl_filter *f;
     
    23222329 * the filter, which the caller must free.
    23232330 */
    2324 CALLER_OWN char *owl_function_zuserfilt(const char *longuser)
     2331G_GNUC_WARN_UNUSED_RESULT char *owl_function_zuserfilt(const char *longuser)
    23252332{
    23262333  owl_filter *f;
     
    23682375 * Returns the name of the filter, which the caller must free.
    23692376 */
    2370 CALLER_OWN char *owl_function_aimuserfilt(const char *user)
     2377G_GNUC_WARN_UNUSED_RESULT char *owl_function_aimuserfilt(const char *user)
    23712378{
    23722379  owl_filter *f;
     
    24062413}
    24072414
    2408 CALLER_OWN char *owl_function_typefilt(const char *type)
     2415G_GNUC_WARN_UNUSED_RESULT char *owl_function_typefilt(const char *type)
    24092416{
    24102417  owl_filter *f;
     
    24622469}
    24632470
    2464 static CALLER_OWN char *owl_function_smartfilter_cc(const owl_message *m)
     2471static G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter_cc(const owl_message *m)
    24652472{
    24662473  const char *ccs;
     
    25142521 *    name to the AIM conversation with that user
    25152522 */
    2516 CALLER_OWN char *owl_function_smartfilter(int type, int invert_related)
     2523G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter(int type, int invert_related)
    25172524{
    25182525  const owl_view *v;
     
    27732780
    27742781  owl_function_punt(argv->len, (const char *const*) argv->pdata, direction);
    2775   owl_ptr_array_free(argv, g_free);
     2782  g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
     2783  g_ptr_array_free(argv, true);
    27762784}
    27772785
     
    27792787{
    27802788  owl_filter *f;
    2781   GPtrArray *fl;
    2782   int i;
     2789  owl_list *fl;
     2790  int i, j;
    27832791  fl=owl_global_get_puntlist(&g);
    27842792
     
    27912799
    27922800  /* Check for an identical filter */
    2793   for (i = 0; i < fl->len; i++) {
    2794     if (owl_filter_equiv(f, fl->pdata[i])) {
     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))) {
    27952804      owl_function_debugmsg("found an equivalent punt filter");
    27962805      /* if we're punting, then just silently bow out on this duplicate */
     
    28022811      /* if we're unpunting, then remove this filter from the puntlist */
    28032812      if (direction==1) {
    2804         owl_filter_delete(g_ptr_array_remove_index(fl, i));
     2813        owl_filter_delete(owl_list_get_element(fl, i));
     2814        owl_list_remove_element(fl, i);
    28052815        owl_filter_delete(f);
    28062816        return;
     
    28122822    owl_function_debugmsg("punting");
    28132823    /* If we're punting, add the filter to the global punt list */
    2814     g_ptr_array_add(fl, f);
     2824    owl_list_append_element(fl, f);
    28152825  } else if (direction == 1) {
    28162826    owl_function_makemsg("No matching punt filter");
     
    28202830void owl_function_show_keymaps(void)
    28212831{
    2822   GPtrArray *l;
     2832  owl_list l;
    28232833  owl_fmtext fm;
    28242834  const owl_keymap *km;
    28252835  const owl_keyhandler *kh;
    2826   int i;
     2836  int i, numkm;
    28272837  const char *kmname;
    28282838
     
    28312841  owl_fmtext_append_bold(&fm, "Keymaps:   ");
    28322842  owl_fmtext_append_normal(&fm, "(use 'show keymap <name>' for details)\n");
    2833   l = owl_keyhandler_get_keymap_names(kh);
    2834   owl_fmtext_append_list(&fm, l, "\n", owl_function_keymap_summary);
     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);
    28352846  owl_fmtext_append_normal(&fm, "\n");
    28362847
    2837   for (i = 0; i < l->len; i++) {
    2838     kmname = l->pdata[i];
     2848  numkm = owl_list_get_size(&l);
     2849  for (i=0; i<numkm; i++) {
     2850    kmname = owl_list_get_element(&l, i);
    28392851    km = owl_keyhandler_get_keymap(kh, kmname);
    28402852    owl_fmtext_append_bold(&fm, "\n\n----------------------------------------------------------------------------------------------------\n\n");
     
    28442856 
    28452857  owl_function_popless_fmtext(&fm);
    2846   owl_ptr_array_free(l, g_free);
     2858  owl_list_cleanup(&l, g_free);
    28472859  owl_fmtext_cleanup(&fm);
    28482860}
    28492861
    2850 CALLER_OWN char *owl_function_keymap_summary(const char *name)
     2862G_GNUC_WARN_UNUSED_RESULT char *owl_function_keymap_summary(const char *name)
    28512863{
    28522864  const owl_keymap *km
     
    29622974/* strips formatting from ztext and returns the unformatted text.
    29632975 * caller is responsible for freeing. */
    2964 CALLER_OWN char *owl_function_ztext_stylestrip(const char *zt)
     2976G_GNUC_WARN_UNUSED_RESULT char *owl_function_ztext_stylestrip(const char *zt)
    29652977{
    29662978  owl_fmtext fm;
     
    29852997#ifdef HAVE_LIBZEPHYR
    29862998  int x;
    2987   GPtrArray *anyone;
     2999  owl_list anyone;
    29883000  const char *user;
    29893001  char *tmp;
     
    30203032    } else {
    30213033      owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n");
    3022       anyone = owl_zephyr_get_anyone_list(filename);
    3023       if (anyone == NULL) {
     3034      owl_list_create(&anyone);
     3035      ret=owl_zephyr_get_anyone_list(&anyone, filename);
     3036      if (ret) {
    30243037        if (errno == ENOENT) {
    30253038          owl_fmtext_append_normal(&fm, " You have not added any zephyr buddies.  Use the\n");
     
    30313044        }
    30323045      } else {
    3033         for (i = 0; i < anyone->len; i++) {
    3034           user = anyone->pdata[i];
     3046        j=owl_list_get_size(&anyone);
     3047        for (i=0; i<j; i++) {
     3048          user=owl_list_get_element(&anyone, i);
    30353049          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30363050
     
    30643078        }
    30653079      }
    3066       owl_ptr_array_free(anyone, g_free);
     3080      owl_list_cleanup(&anyone, g_free);
    30673081    }
    30683082  }
     
    33763390{
    33773391#ifdef HAVE_LIBZEPHYR
    3378   int i;
    3379   GPtrArray *anyone;
     3392  int i, j;
     3393  owl_list anyone;
    33803394  GList **zaldlist;
    33813395  GList *zaldptr;
     
    33973411  *zaldlist = NULL;
    33983412
    3399   anyone = owl_zephyr_get_anyone_list(NULL);
    3400   for (i = 0; i < anyone->len; i++) {
    3401     user = anyone->pdata[i];
     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);
    34023418    zald = g_new(ZAsyncLocateData_t, 1);
    34033419    if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
     
    34083424  }
    34093425
    3410   owl_ptr_array_free(anyone, g_free);
     3426  owl_list_cleanup(&anyone, g_free);
    34113427#endif
    34123428}
    34133429
    3414 void owl_function_aimsearch_results(const char *email, GPtrArray *namelist)
     3430void owl_function_aimsearch_results(const char *email, owl_list *namelist)
    34153431{
    34163432  owl_fmtext fm;
    3417   int i;
     3433  int i, j;
    34183434
    34193435  owl_fmtext_init_null(&fm);
     
    34223438  owl_fmtext_append_normal(&fm, ":\n");
    34233439
    3424   for (i = 0; i < namelist->len; i++) {
     3440  j=owl_list_get_size(namelist);
     3441  for (i=0; i<j; i++) {
    34253442    owl_fmtext_append_normal(&fm, "  ");
    3426     owl_fmtext_append_normal(&fm, namelist->pdata[i]);
     3443    owl_fmtext_append_normal(&fm, owl_list_get_element(namelist, i));
    34273444    owl_fmtext_append_normal(&fm, "\n");
    34283445  }
  • global.c

    r2560529 r43744ce  
    4747  owl_dict_create(&(g->filters));
    4848  g->filterlist = NULL;
    49   g->puntlist = g_ptr_array_new();
     49  owl_list_create(&(g->puntlist));
    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 CALLER_OWN owl_context *owl_global_pop_context_no_delete(owl_global *g)
     174G_GNUC_WARN_UNUSED_RESULT owl_context *owl_global_pop_context_no_delete(owl_global *g)
    175175{
    176176  owl_context *c;
     
    579579/* puntlist */
    580580
    581 GPtrArray *owl_global_get_puntlist(owl_global *g) {
    582   return g->puntlist;
     581owl_list *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 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;
     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);
    594595}
    595596
     
    724725 * necessary.
    725726 */
    726 CALLER_OWN owl_message *owl_global_messagequeue_popmsg(owl_global *g)
     727owl_message G_GNUC_WARN_UNUSED_RESULT *owl_global_messagequeue_popmsg(owl_global *g)
    727728{
    728729  owl_message *out;
     
    753754}
    754755
    755 CALLER_OWN GPtrArray *owl_global_get_style_names(const owl_global *g)
    756 {
    757   return owl_dict_get_keys(&g->styledict);
     756void owl_global_get_style_names(const owl_global *g, owl_list *l) {
     757  owl_dict_get_keys(&(g->styledict), l);
    758758}
    759759
  • help.c

    rce68f23 rf25df21  
    66  owl_fmtext fm;
    77  const char *varname;
    8   GPtrArray *varnames;
    9   int i;
     8  owl_list varnames;
     9  int i, numvarnames;
    1010
    1111  owl_fmtext_init_null(&fm);
     
    129129  owl_fmtext_append_bold(&fm,
    130130                         "Variables:\n");
    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];
     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);
    134136    if (varname && varname[0]!='_') {
    135137      owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    136138    }
    137139  }
    138   owl_ptr_array_free(varnames, g_free);
     140  owl_list_cleanup(&varnames, g_free);
    139141
    140142  owl_fmtext_append_normal(&fm, "\n");
  • keybinding.c

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

    rce68f23 rd427f08  
    1111  km->name = g_strdup(name);
    1212  km->desc = g_strdup(desc);
    13   km->bindings = g_ptr_array_new();
     13  owl_list_create(&km->bindings);
    1414  km->parent = NULL;
    1515  km->default_fn = default_fn;
     
    2424  g_free(km->name);
    2525  g_free(km->desc);
    26   owl_ptr_array_free(km->bindings, (GDestroyNotify)owl_keybinding_delete);
     26  owl_list_cleanup(&km->bindings, (void (*)(void *))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;
     37  owl_keybinding *kb, *curkb;
    3838  int i;
    3939
     
    4444   * otherwise just add this one.
    4545   */
    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);
     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);
    5254  return 0;
    5355}
     
    5658int owl_keymap_remove_binding(owl_keymap *km, const char *keyseq)
    5759{
    58   owl_keybinding *kb;
     60  owl_keybinding *kb, *curkb;
    5961  int i;
    6062
     
    6365    return -1;
    6466
    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));
     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);
    6872      owl_keybinding_delete(kb);
    6973      return(0);
     
    7680
    7781/* returns a summary line describing this keymap.  the caller must free. */
    78 CALLER_OWN char *owl_keymap_summary(const owl_keymap *km)
     82G_GNUC_WARN_UNUSED_RESULT char *owl_keymap_summary(const owl_keymap *km)
    7983{
    8084  if (!km || !km->name || !km->desc) return NULL;
     
    135139static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm)
    136140{
    137   int i;
     141  int i, nbindings;
    138142  const owl_keybinding *kb;
    139143 
    140   for (i = 0; i < km->bindings->len; i++) {
     144  nbindings = owl_list_get_size(&km->bindings);
     145  for (i=0; i<nbindings; i++) {
    141146    char *kbstr;
    142147    const owl_cmd *cmd;
    143148    const char *tmpdesc, *desc = "";
    144149
    145     kb = km->bindings->pdata[i];
     150    kb = owl_list_get_element(&km->bindings, i);
    146151    kbstr = owl_keybinding_tostring(kb);
    147152    owl_fmtext_append_normal(fm, OWL_TABSTR);
     
    209214}
    210215
    211 CALLER_OWN GPtrArray *owl_keyhandler_get_keymap_names(const owl_keyhandler *kh)
    212 {
    213   return owl_dict_get_keys(&kh->keymaps);
     216void owl_keyhandler_get_keymap_names(const owl_keyhandler *kh, owl_list *l)
     217{
     218  owl_dict_get_keys(&kh->keymaps, l);
    214219}
    215220
     
    269274   * keyhandler and keymap apart.  */
    270275  for (km=kh->active; km; km=km->parent) {
    271     for (i = km->bindings->len-1; i >= 0; i--) {
    272       kb = km->bindings->pdata[i];
     276    for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) {
     277      kb = owl_list_get_element(&km->bindings, i);
    273278      match = owl_keybinding_match(kb, kh);
    274279      if (match == 1) {         /* subset match */
  • keypress.c

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

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

    rf9df2f0 rd427f08  
    4343
    4444  owl_message_set_hostname(m, "");
    45   m->attributes = g_ptr_array_new();
     45  owl_list_create(&(m->attributes));
    4646 
    4747  /* save the time */
     
    5858void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue)
    5959{
    60   int i;
     60  int i, j;
    6161  owl_pair *p = NULL, *pair = NULL;
    6262
     
    6464
    6565  /* look for an existing pair with this key, */
    66   for (i = 0; i < m->attributes->len; i++) {
    67     p = m->attributes->pdata[i];
     66  j=owl_list_get_size(&(m->attributes));
     67  for (i=0; i<j; i++) {
     68    p=owl_list_get_element(&(m->attributes), i);
    6869    if (owl_pair_get_key(p) == attrname) {
    6970      g_free(owl_pair_get_value(p));
     
    7677    pair = g_new(owl_pair, 1);
    7778    owl_pair_create(pair, attrname, NULL);
    78     g_ptr_array_add(m->attributes, pair);
     79    owl_list_append_element(&(m->attributes), pair);
    7980  }
    8081  owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
     
    8687const char *owl_message_get_attribute_value(const owl_message *m, const char *attrname)
    8788{
    88   int i;
     89  int i, j;
    8990  owl_pair *p;
    9091  GQuark quark;
     
    9697  attrname = g_quark_to_string(quark);
    9798
    98   for (i = 0; i < m->attributes->len; i++) {
    99     p = m->attributes->pdata[i];
     99  j=owl_list_get_size(&(m->attributes));
     100  for (i=0; i<j; i++) {
     101    p=owl_list_get_element(&(m->attributes), i);
    100102    if (owl_pair_get_key(p) == attrname) {
    101103      return(owl_pair_get_value(p));
     
    116118 */
    117119void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) {
    118   int i;
     120  int i, j;
    119121  owl_pair *p;
    120122  char *buff, *tmpbuff;
     
    122124  owl_fmtext_init_null(fm);
    123125
    124   for (i = 0; i < m->attributes->len; i++) {
    125     p = m->attributes->pdata[i];
     126  j=owl_list_get_size(&(m->attributes));
     127  for (i=0; i<j; i++) {
     128    p=owl_list_get_element(&(m->attributes), i);
    126129
    127130    tmpbuff = g_strdup(owl_pair_get_value(p));
     
    577580
    578581/* caller must free return value. */
    579 CALLER_OWN char *owl_message_get_cc(const owl_message *m)
     582G_GNUC_WARN_UNUSED_RESULT char *owl_message_get_cc(const owl_message *m)
    580583{
    581584  const char *cur;
     
    594597
    595598/* caller must free return value */
    596 CALLER_OWN GList *owl_message_get_cc_without_recipient(const owl_message *m)
     599G_GNUC_WARN_UNUSED_RESULT GList *owl_message_get_cc_without_recipient(const owl_message *m)
    597600{
    598601  char *cc, *shortuser, *recip;
     
    10011004void owl_message_cleanup(owl_message *m)
    10021005{
    1003   int i;
     1006  int i, j;
    10041007  owl_pair *p;
    10051008#ifdef HAVE_LIBZEPHYR   
     
    10111014
    10121015  /* free all the attributes */
    1013   for (i = 0; i < m->attributes->len; i++) {
    1014     p = m->attributes->pdata[i];
     1016  j=owl_list_get_size(&(m->attributes));
     1017  for (i=0; i<j; i++) {
     1018    p=owl_list_get_element(&(m->attributes), i);
    10151019    g_free(owl_pair_get_value(p));
    10161020    g_free(p);
    10171021  }
    10181022
    1019   g_ptr_array_free(m->attributes, true);
     1023  owl_list_cleanup(&(m->attributes), NULL);
    10201024 
    10211025  owl_message_invalidate_format(m);
  • messagelist.c

    rfc8a87a rd427f08  
    33#include <string.h>
    44
    5 void owl_messagelist_create(owl_messagelist *ml)
     5int owl_messagelist_create(owl_messagelist *ml)
    66{
    7   ml->list = g_ptr_array_new();
    8 }
    9 
    10 void 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);
     7  owl_list_create(&(ml->list));
     8  return(0);
    159}
    1610
    1711int owl_messagelist_get_size(const owl_messagelist *ml)
    1812{
    19   return ml->list->len;
     13  return(owl_list_get_size(&(ml->list)));
    2014}
    2115
    2216void *owl_messagelist_get_element(const owl_messagelist *ml, int n)
    2317{
    24   return ml->list->pdata[n];
     18  return(owl_list_get_element(&(ml->list), n));
    2519}
    2620
     
    3226
    3327  first = 0;
    34   last = ml->list->len - 1;
     28  last = owl_list_get_size(&(ml->list)) - 1;
    3529  while (first <= last) {
    3630    mid = (first + last) / 2;
    37     m = ml->list->pdata[mid];
     31    m = owl_list_get_element(&(ml->list), mid);
    3832    msg_id = owl_message_get_id(m);
    3933    if (msg_id == target_id) {
     
    5044void owl_messagelist_append_element(owl_messagelist *ml, void *element)
    5145{
    52   g_ptr_array_add(ml->list, element);
     46  owl_list_append_element(&ml->list, element);
    5347}
    5448
     
    5751{
    5852  /* mark a message as deleted */
    59   owl_message_mark_delete(ml->list->pdata[n]);
     53  owl_message_mark_delete(owl_list_get_element(&(ml->list), n));
    6054  return(0);
    6155}
     
    6458{
    6559  /* mark a message as deleted */
    66   owl_message_unmark_delete(ml->list->pdata[n]);
     60  owl_message_unmark_delete(owl_list_get_element(&(ml->list), n));
    6761  return(0);
    6862}
     
    7165{
    7266  /* expunge deleted messages */
    73   int i;
    74   GPtrArray *newlist;
     67  int i, j;
     68  owl_list newlist;
    7569  owl_message *m;
    7670
    77   newlist = g_ptr_array_new();
     71  owl_list_create(&newlist);
    7872  /*create a new list without messages marked as deleted */
    79   for (i = 0; i < ml->list->len; i++) {
    80     m = ml->list->pdata[i];
     73  j=owl_list_get_size(&(ml->list));
     74  for (i=0; i<j; i++) {
     75    m=owl_list_get_element(&(ml->list), i);
    8176    if (owl_message_is_delete(m)) {
    8277      owl_message_delete(m);
    8378    } else {
    84       g_ptr_array_add(newlist, m);
     79      owl_list_append_element(&newlist, m);
    8580    }
    8681  }
    8782
    8883  /* free the old list */
    89   g_ptr_array_free(ml->list, true);
     84  owl_list_cleanup(&(ml->list), NULL);
    9085
    9186  /* copy the new list to the old list */
     
    9792void owl_messagelist_invalidate_formats(const owl_messagelist *ml)
    9893{
    99   int i;
     94  int i, j;
    10095  owl_message *m;
    10196
    102   for (i = 0; i < ml->list->len; i++) {
    103     m = ml->list->pdata[i];
     97  j=owl_list_get_size(&(ml->list));
     98  for (i=0; i<j; i++) {
     99    m=owl_list_get_element(&(ml->list), i);
    104100    owl_message_invalidate_format(m);
    105101  }
  • owl.h

    r2560529 r95b52d1  
    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
    205201
    206202#define OWL_META(key) ((key)|010000)
     
    255251                                 * WARNING:  this approach is hard to make
    256252                                 * thread-safe... */
    257   CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
     253  char G_GNUC_WARN_UNUSED_RESULT *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    258254                                /* converts val to a string;
    259255                                 * caller must free the result */
     
    270266  GString *buff;
    271267} owl_fmtext;
     268
     269typedef struct _owl_list {
     270  int size;
     271  int avail;
     272  void **list;
     273} owl_list;
    272274
    273275typedef struct _owl_dict_el {
     
    311313 
    312314  /* These don't take any context */
    313   CALLER_OWN char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
     315  char G_GNUC_WARN_UNUSED_RESULT *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
    314316                                /* takes argv and the full command as buff.
    315317                                 * caller must free return value if !NULL */
     
    318320
    319321  /* The following also take the active context if it's valid */
    320   CALLER_OWN char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
     322  char G_GNUC_WARN_UNUSED_RESULT *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
    321323                                /* takes argv and the full command as buff.
    322324                                 * caller must free return value if !NULL */
     
    336338  char *zsig;
    337339  char *message;
    338   GPtrArray *recips;
     340  owl_list recips;
    339341  int cc;
    340342  int noping;
     
    357359  int delete;
    358360  const char *hostname;
    359   GPtrArray *attributes;          /* this is a list of pairs */
     361  owl_list attributes;            /* this is a list of pairs */
    360362  char *timestr;
    361363  time_t time;
     
    416418
    417419typedef struct _owl_messagelist {
    418   GPtrArray *list;
     420  owl_list list;
    419421} owl_messagelist;
    420422
     
    479481  char     *name;               /* name of keymap */
    480482  char     *desc;               /* description */
    481   GPtrArray *bindings;          /* key bindings */
     483  owl_list  bindings;           /* key bindings */
    482484  const struct _owl_keymap *parent;     /* parent */
    483485  void (*default_fn)(owl_input j);      /* default action (takes a keypress) */
     
    502504
    503505typedef struct _owl_buddylist {
    504   GPtrArray *buddies;
     506  owl_list buddies;
    505507} owl_buddylist;
    506508
    507509typedef struct _owl_zbuddylist {
    508   GPtrArray *zusers;
     510  owl_list zusers;
    509511} owl_zbuddylist;
    510512
    511513typedef struct _owl_errqueue {
    512   GPtrArray *errlist;
     514  owl_list errlist;
    513515} owl_errqueue;
    514516
     
    536538  owl_dict filters;
    537539  GList *filterlist;
    538   GPtrArray *puntlist;
     540  owl_list puntlist;
    539541  owl_vardict vars;
    540542  owl_cmddict cmds;
  • perlconfig.c

    rce68f23 rd427f08  
    2323
    2424
    25 CALLER_OWN SV *owl_new_sv(const char * str)
     25G_GNUC_WARN_UNUSED_RESULT SV *owl_new_sv(const char * str)
    2626{
    2727  SV *ret = newSVpv(str, 0);
     
    3636}
    3737
    38 CALLER_OWN AV *owl_new_av(const GPtrArray *l, SV *(*to_sv)(const void *))
     38G_GNUC_WARN_UNUSED_RESULT AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))
    3939{
    4040  AV *ret;
     
    4444  ret = newAV();
    4545
    46   for (i = 0; i < l->len; i++) {
    47     element = l->pdata[i];
     46  for (i = 0; i < owl_list_get_size(l); i++) {
     47    element = owl_list_get_element(l, i);
    4848    av_push(ret, to_sv(element));
    4949  }
     
    5252}
    5353
    54 CALLER_OWN HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
     54G_GNUC_WARN_UNUSED_RESULT HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
    5555{
    5656  HV *ret;
    57   GPtrArray *keys;
     57  owl_list l;
    5858  const char *key;
    5959  void *element;
     
    6363
    6464  /* TODO: add an iterator-like interface to owl_dict */
    65   keys = owl_dict_get_keys(d);
    66   for (i = 0; i < keys->len; i++) {
    67     key = keys->pdata[i];
     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);
    6869    element = owl_dict_find_element(d, key);
    6970    (void)hv_store(ret, key, strlen(key), to_sv(element), 0);
    7071  }
    71   owl_ptr_array_free(keys, g_free);
     72  owl_list_cleanup(&l, g_free);
    7273
    7374  return ret;
    7475}
    7576
    76 CALLER_OWN SV *owl_perlconfig_message2hashref(const owl_message *m)
     77G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_message2hashref(const owl_message *m)
    7778{
    7879  HV *h, *stash;
     
    114115  }
    115116
    116   for (i = 0; i < m->attributes->len; i++) {
    117     pair = m->attributes->pdata[i];
     117  j=owl_list_get_size(&(m->attributes));
     118  for(i=0; i<j; i++) {
     119    pair=owl_list_get_element(&(m->attributes), i);
    118120    (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
    119121                   owl_new_sv(owl_pair_get_value(pair)),0);
     
    163165}
    164166
    165 CALLER_OWN SV *owl_perlconfig_curmessage2hashref(void)
     167G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_curmessage2hashref(void)
    166168{
    167169  int curmsg;
     
    181183   This has been somewhat addressed, but is still not lossless.
    182184 */
    183 CALLER_OWN owl_message *owl_perlconfig_hashref2message(SV *msg)
     185G_GNUC_WARN_UNUSED_RESULT owl_message *owl_perlconfig_hashref2message(SV *msg)
    184186{
    185187  owl_message * m;
     
    249251/* Calls in a scalar context, passing it a hash reference.
    250252   If return value is non-null, caller must free. */
    251 CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
     253G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    252254{
    253255  dSP ;
     
    298300   If the return value is non-null, the caller must free it.
    299301 */
    300 CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
     302G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    301303{
    302304  dSP;
     
    348350
    349351/* caller must free result, if not NULL */
    350 CALLER_OWN char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
     352G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
    351353{
    352354  int ret;
     
    434436
    435437/* caller is responsible for freeing returned string */
    436 CALLER_OWN char *owl_perlconfig_execute(const char *line)
     438G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_execute(const char *line)
    437439{
    438440  STRLEN len;
     
    504506
    505507/* caller must free the result */
    506 CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
     508G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    507509{
    508510  int i, count;
  • perlglue.xs

    rce68f23 rbcde7926  
    329329all_filters()
    330330        PREINIT:
    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);
     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);
    336337                sv_2mortal((SV*)RETVAL);
    337                 owl_ptr_array_free(fl, g_free);
     338                owl_list_cleanup(&fl, g_free);
    338339        }
    339340        OUTPUT:
     
    343344all_styles()
    344345        PREINIT:
    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);
     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);
    350352                sv_2mortal((SV*)RETVAL);
    351353        }
     
    353355                RETVAL
    354356        CLEANUP:
    355                 owl_ptr_array_free(l, g_free);
     357                owl_list_cleanup(&l, g_free);
    356358
    357359
     
    359361all_variables()
    360362        PREINIT:
    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);
     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);
    366369                sv_2mortal((SV*)RETVAL);
    367370        }
     
    369372                RETVAL
    370373        CLEANUP:
    371                 owl_ptr_array_free(l, g_free);
     374                owl_list_cleanup(&l, g_free);
    372375
    373376
     
    375378all_keymaps()
    376379        PREINIT:
    377                 GPtrArray *l;
     380                owl_list l;
    378381                const owl_keyhandler *kh;
    379382        CODE:
    380383        {
    381384                kh = owl_global_get_keyhandler(&g);
    382                 l = owl_keyhandler_get_keymap_names(kh);
    383                 RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv);
     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);
    384388                sv_2mortal((SV*)RETVAL);
    385389        }
     
    387391                RETVAL
    388392        CLEANUP:
    389                 owl_ptr_array_free(l, g_free);
     393                owl_list_cleanup(&l, g_free);
    390394
    391395void
  • popwin.c

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

    rce68f23 r4e37d56  
    230230int owl_dict_regtest(void) {
    231231  owl_dict d;
    232   GPtrArray *l;
     232  owl_list 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   l = owl_dict_get_keys(&d);
    254   FAIL_UNLESS("get_keys result size", 3 == l->len);
     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));
    255256 
    256257  /* these assume the returned keys are sorted */
    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);
     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);
    262263  owl_dict_cleanup(&d, NULL);
    263264
  • text.c

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

    r3cdd6d2 rd427f08  
    3535 * duplicate slashes are removed.  Caller must free the return.
    3636 */
    37 CALLER_OWN char *owl_util_makepath(const char *in)
     37G_GNUC_WARN_UNUSED_RESULT char *owl_util_makepath(const char *in)
    3838{
    3939  int i, j, x;
     
    9898}
    9999
    100 void 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 
    109100/* Break a command line up into argv, argc.  The caller must free
    110101   the returned values with g_strfreev.  If there is an error argc will be set
    111102   to -1, argv will be NULL and the caller does not need to free anything. The
    112103   returned vector is NULL-terminated. */
    113 CALLER_OWN char **owl_parseline(const char *line, int *argc)
     104G_GNUC_WARN_UNUSED_RESULT char **owl_parseline(const char *line, int *argc)
    114105{
    115106  GPtrArray *argv;
     
    179170  /* check for unbalanced quotes */
    180171  if (quote!='\0') {
    181     owl_ptr_array_free(argv, g_free);
     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);
    182176    if (argc) *argc = -1;
    183177    return(NULL);
     
    251245}
    252246
    253 CALLER_OWN char *owl_string_build_quoted(const char *tmpl, ...)
     247G_GNUC_WARN_UNUSED_RESULT char *owl_string_build_quoted(const char *tmpl, ...)
    254248{
    255249  GString *buf = g_string_new("");
     
    263257/* Returns a quoted version of arg suitable for placing in a
    264258 * command-line. Result should be freed with g_free. */
    265 CALLER_OWN char *owl_arg_quote(const char *arg)
     259G_GNUC_WARN_UNUSED_RESULT char *owl_arg_quote(const char *arg)
    266260{
    267261  GString *buf = g_string_new("");;
     
    271265
    272266/* caller must free the return */
    273 CALLER_OWN char *owl_util_minutes_to_timestr(int in)
     267G_GNUC_WARN_UNUSED_RESULT char *owl_util_minutes_to_timestr(int in)
    274268{
    275269  int days, hours;
     
    337331
    338332/* Get the default tty name.  Caller must free the return */
    339 CALLER_OWN char *owl_util_get_default_tty(void)
     333G_GNUC_WARN_UNUSED_RESULT char *owl_util_get_default_tty(void)
    340334{
    341335  const char *tmp;
     
    359353 * return.
    360354 */
    361 CALLER_OWN char *owl_util_stripnewlines(const char *in)
     355G_GNUC_WARN_UNUSED_RESULT char *owl_util_stripnewlines(const char *in)
    362356{
    363357 
     
    390384 * Error conditions are the same as g_file_read_link.
    391385 */
    392 CALLER_OWN gchar *owl_util_recursive_resolve_link(const char *filename)
     386G_GNUC_WARN_UNUSED_RESULT gchar *owl_util_recursive_resolve_link(const char *filename)
    393387{
    394388  gchar *last_path = g_strdup(filename);
     
    517511   The caller is responsible for freeing the allocated string.
    518512*/
    519 CALLER_OWN char *owl_util_baseclass(const char *class)
     513G_GNUC_WARN_UNUSED_RESULT char *owl_util_baseclass(const char *class)
    520514{
    521515  char *start, *end;
     
    553547/* Strips format characters from a valid utf-8 string. Returns the
    554548   empty string if 'in' does not validate.  Caller must free the return. */
    555 CALLER_OWN char *owl_strip_format_chars(const char *in)
     549G_GNUC_WARN_UNUSED_RESULT char *owl_strip_format_chars(const char *in)
    556550{
    557551  char *r;
     
    592586 * Caller must free the return.
    593587 */
    594 CALLER_OWN char *owl_validate_or_convert(const char *in)
     588G_GNUC_WARN_UNUSED_RESULT char *owl_validate_or_convert(const char *in)
    595589{
    596590  if (g_utf8_validate(in, -1, NULL)) {
     
    608602 * Caller must free the return.
    609603 */
    610 CALLER_OWN char *owl_validate_utf8(const char *in)
     604G_GNUC_WARN_UNUSED_RESULT char *owl_validate_utf8(const char *in)
    611605{
    612606  char *out;
     
    641635
    642636/* caller must free the return */
    643 CALLER_OWN char *owl_escape_highbit(const char *str)
     637G_GNUC_WARN_UNUSED_RESULT char *owl_escape_highbit(const char *str)
    644638{
    645639  GString *out = g_string_new("");
     
    704698
    705699/* Read the rest of the input available in fp into a string. */
    706 CALLER_OWN char *owl_slurp(FILE *fp)
     700G_GNUC_WARN_UNUSED_RESULT char *owl_slurp(FILE *fp)
    707701{
    708702  char *buf = NULL;
  • variable.c

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

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

    r6829afc rd427f08  
    1212 * will be used by the viewwin
    1313 */
    14 CALLER_OWN owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
     14G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
     36G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
    3737{
    3838  char *text;
     
    237237}
    238238
    239 CALLER_OWN owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
     239G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
    240240  int lines, cols;
    241241  owl_editwin *cmdline;
  • window.c

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

    r7ed9bc6 rddbbcffa  
    33void owl_zbuddylist_create(owl_zbuddylist *zb)
    44{
    5   zb->zusers = g_ptr_array_new();
     5  owl_list_create(&(zb->zusers));
    66}
    77
    88int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name)
    99{
    10   int i;
     10  int i, j;
    1111  char *user;
    1212
    1313  user=long_zuser(name);
    1414
    15   for (i = 0; i < zb->zusers->len; i++) {
    16     if (!strcasecmp(user, zb->zusers->pdata[i])) {
     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))) {
    1718      g_free(user);
    1819      return(-1);
    1920    }
    2021  }
    21   g_ptr_array_add(zb->zusers, user);
     22  owl_list_append_element(&(zb->zusers), user);
    2223  return(0);
    2324}
     
    2526int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name)
    2627{
    27   int i;
    28   char *user;
     28  int i, j;
     29  char *user, *ptr;
    2930
    3031  user=long_zuser(name);
    3132
    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));
     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);
    3539      g_free(user);
    3640      return(0);
     
    4347int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name)
    4448{
    45   int i;
     49  int i, j;
    4650  char *user;
    4751
    4852  user=long_zuser(name);
    4953
    50   for (i = 0; i < zb->zusers->len; i++) {
    51     if (!strcasecmp(user, zb->zusers->pdata[i])) {
     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))) {
    5257      g_free(user);
    5358      return(1);
  • zcrypt.c

    r6829afc rd427f08  
    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 
    3329#define MAX_KEY      128
    3430#define MAX_LINE     128
     
    5753} ZWRITEOPTIONS;
    5854
    59 CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
     55G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
    6056int ParseCryptSpec(const char *spec, const char **keyfile);
    61 CALLER_OWN char *BuildArgString(char **argv, int start, int end);
    62 CALLER_OWN char *read_keystring(const char *keyfile);
     57G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end);
     58G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile);
    6359
    6460int do_encrypt(int zephyr, const char *class, const char *instance,
     
    368364/* Build a space-separated string from argv from elements between start  *
    369365 * and end - 1.  malloc()'s the returned string. */
    370 CALLER_OWN char *BuildArgString(char **argv, int start, int end)
     366G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end)
    371367{
    372368  int len = 1;
     
    405401#define MAX_SEARCH 3
    406402/* Find the class/instance in the .crypt-table */
    407 CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
     403G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
    408404{
    409405  char *keyfile = NULL;
     
    583579}
    584580
    585 CALLER_OWN char *slurp_stdin(int ignoredot, int *length) {
     581G_GNUC_WARN_UNUSED_RESULT char *slurp_stdin(int ignoredot, int *length) {
    586582  char *buf;
    587583  char *inptr;
     
    615611}
    616612
    617 CALLER_OWN char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
     613G_GNUC_WARN_UNUSED_RESULT char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
    618614  char *buf;
    619615
     
    641637}
    642638
    643 CALLER_OWN char *read_keystring(const char *keyfile) {
     639G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile) {
    644640  char *keystring;
    645641  FILE *fkey = fopen(keyfile, "r");
  • zephyr.c

    recffae6 rd427f08  
    524524 */
    525525#ifdef HAVE_LIBZEPHYR
    526 CALLER_OWN char *owl_zephyr_get_field(const ZNotice_t *n, int j)
     526G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(const ZNotice_t *n, int j)
    527527{
    528528  int i, count, save;
     
    552552}
    553553
    554 CALLER_OWN char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
     554G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
    555555{
    556556  int i, count, save;
     
    584584}
    585585#else
    586 CALLER_OWN char *owl_zephyr_get_field(void *n, int j)
     586G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(void *n, int j)
    587587{
    588588  return(g_strdup(""));
    589589}
    590 CALLER_OWN char *owl_zephyr_get_field_as_utf8(void *n, int j)
     590G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
     623G_GNUC_WARN_UNUSED_RESULT 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       zw.recips = g_ptr_array_new();
    841       g_ptr_array_add(zw.recips, g_strdup(retnotice->z_recipient));
     840      owl_list_create(&(zw.recips));
     841      owl_list_append_element(&(zw.recips), g_strdup(retnotice->z_recipient));
    842842
    843843      owl_log_outgoing_zephyr_error(&zw, buff);
     
    942942#endif
    943943
    944 CALLER_OWN char *owl_zephyr_zlocate(const char *user, int auth)
     944G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_zlocate(const char *user, int auth)
    945945{
    946946#ifdef HAVE_LIBZEPHYR
     
    10421042
    10431043/* caller must free the return */
    1044 CALLER_OWN char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
     1044G_GNUC_WARN_UNUSED_RESULT 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 CALLER_OWN char *owl_zephyr_getsubs(void)
     1124G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_getsubs(void)
    11251125{
    11261126#ifdef HAVE_LIBZEPHYR
     
    12421242 * The caller must free the return
    12431243 */
    1244 CALLER_OWN char *short_zuser(const char *in)
     1244G_GNUC_WARN_UNUSED_RESULT char *short_zuser(const char *in)
    12451245{
    12461246  char *ptr = strrchr(in, '@');
     
    12541254 * The caller must free the return.
    12551255 */
    1256 CALLER_OWN char *long_zuser(const char *in)
     1256G_GNUC_WARN_UNUSED_RESULT char *long_zuser(const char *in)
    12571257{
    12581258  char *ptr = strrchr(in, '@');
     
    12821282 * caller must free the return.
    12831283 */
    1284 CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in)
     1284G_GNUC_WARN_UNUSED_RESULT 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 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.
     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.
    13291330 */
    1330 GPtrArray *owl_zephyr_get_anyone_list(const char *filename)
     1331int owl_zephyr_get_anyone_list(owl_list *in, const char *filename)
    13311332{
    13321333#ifdef HAVE_LIBZEPHYR
    13331334  char *ourfile, *tmp, *s = NULL;
    13341335  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 NULL;
     1343    return -1;
    13441344  }
    13451345  g_free(ourfile);
    13461346
    1347   list = g_ptr_array_new();
    13481347  while (owl_getline_chomp(&s, f)) {
    13491348    /* ignore comments, blank lines etc. */
     
    13611360      tmp[0] = '\0';
    13621361
    1363     g_ptr_array_add(list, long_zuser(s));
     1362    owl_list_append_element(in, long_zuser(s));
    13641363  }
    13651364  g_free(s);
    13661365  fclose(f);
    1367   return list;
    1368 #else
    1369   return NULL;
     1366  return 0;
     1367#else
     1368  return -1;
    13701369#endif
    13711370}
  • zwrite.c

    r3cdd6d2 rd427f08  
    55#include "owl.h"
    66
    7 CALLER_OWN owl_zwrite *owl_zwrite_new(const char *line)
     7G_GNUC_WARN_UNUSED_RESULT 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   z->recips = g_ptr_array_new();
     36  owl_list_create(&(z->recips));
    3737  z->zwriteline = g_strdup(line);
    3838
     
    9797      }
    9898      /* we must already have users or a class or an instance */
    99       if (z->recips->len < 1 && (!z->class) && (!z->inst)) {
     99      if (owl_list_get_size(&(z->recips))<1 && (!z->class) && (!z->inst)) {
    100100        badargs=1;
    101101        break;
     
    117117    } else {
    118118      /* anything unattached is a recipient */
    119       g_ptr_array_add(z->recips, owl_validate_utf8(myargv[0]));
     119      owl_list_append_element(&(z->recips), owl_validate_utf8(myargv[0]));
    120120      myargv++;
    121121      myargc--;
     
    131131  if (z->class == NULL &&
    132132      z->inst == NULL &&
    133       z->recips->len == 0) {
     133      owl_list_get_size(&(z->recips))==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;
     164  int i, j;
    165165  char *to;
    166166
     
    173173  /* if there are no recipients we won't send a ping, which
    174174     is what we want */
    175   for (i = 0; i < z->recips->len; i++) {
     175  j=owl_list_get_size(&(z->recips));
     176  for (i=0; i<j; i++) {
    176177    to = owl_zwrite_get_recip_n_with_realm(z, i);
    177178    send_ping(to, z->class, z->inst);
     
    190191void owl_zwrite_set_message(owl_zwrite *z, const char *msg)
    191192{
    192   int i;
     193  int i, j;
    193194  GString *message;
    194195  char *tmp = NULL, *tmp2;
     
    196197  g_free(z->message);
    197198
    198   if (z->recips->len > 0 && z->cc) {
     199  j=owl_list_get_size(&(z->recips));
     200  if (j>0 && z->cc) {
    199201    message = g_string_new("CC: ");
    200     for (i = 0; i < z->recips->len; i++) {
     202    for (i=0; i<j; i++) {
    201203      tmp = owl_zwrite_get_recip_n_with_realm(z, i);
    202204      g_string_append_printf(message, "%s ", tmp);
     
    231233int owl_zwrite_send_message(const owl_zwrite *z)
    232234{
    233   int i, ret = 0;
     235  int i, j, ret = 0;
    234236  char *to = NULL;
    235237
    236238  if (z->message==NULL) return(-1);
    237239
    238   if (z->recips->len > 0) {
    239     for (i = 0; i < z->recips->len; i++) {
     240  j=owl_list_get_size(&(z->recips));
     241  if (j>0) {
     242    for (i=0; i<j; i++) {
    240243      to = owl_zwrite_get_recip_n_with_realm(z, i);
    241244      ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
     
    309312int owl_zwrite_get_numrecips(const owl_zwrite *z)
    310313{
    311   return z->recips->len;
     314  return(owl_list_get_size(&(z->recips)));
    312315}
    313316
    314317const char *owl_zwrite_get_recip_n(const owl_zwrite *z, int n)
    315318{
    316   return z->recips->pdata[n];
     319  return(owl_list_get_element(&(z->recips), n));
    317320}
    318321
    319322/* Caller must free the result. */
    320 CALLER_OWN char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
     323G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
    321324{
    322325  if (z->realm[0]) {
     
    330333{
    331334  /* return true if at least one of the recipients is personal */
    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;
     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);
    338342  }
    339343  return(0);
     
    348352void owl_zwrite_cleanup(owl_zwrite *z)
    349353{
    350   owl_ptr_array_free(z->recips, g_free);
     354  owl_list_cleanup(&(z->recips), &g_free);
    351355  g_free(z->cmd);
    352356  g_free(z->zwriteline);
     
    366370 * If not a CC, only the recip_index'th user will be replied to.
    367371 */
    368 CALLER_OWN char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
     372G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
    369373{
    370374  /* Match ordering in zwrite help. */
     
    399403  }
    400404  if (z->cc) {
    401     for (i = 0; i < z->recips->len; i++) {
     405    for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {
    402406      g_string_append_c(buf, ' ');
    403       owl_string_append_quoted_arg(buf, z->recips->pdata[i]);
     407      owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i));
    404408    }
    405   } else if (recip_index < z->recips->len) {
     409  } else if (recip_index < owl_list_get_size(&(z->recips))) {
    406410    g_string_append_c(buf, ' ');
    407     owl_string_append_quoted_arg(buf, z->recips->pdata[recip_index]);
     411    owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), recip_index));
    408412  }
    409413
Note: See TracChangeset for help on using the changeset viewer.