Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • dict.c

    r4c7c21f rf271129  
    66 */
    77
    8 #include <stdlib.h>
    9 #include <string.h>
    10 #include <unistd.h>
    118#include "owl.h"
    12 
    139
    1410#define INITSIZE 30
     
    5652}
    5753
    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) {
     54/* Returns a GPtrArray of dictionary keys. Duplicates the keys, so
     55 * they will need to be freed by the caller with g_free. */
     56CALLER_OWN GPtrArray *owl_dict_get_keys(const owl_dict *d) {
     57  GPtrArray *keys = g_ptr_array_sized_new(d->size);
    6158  int i;
    62   for (i=0; i<d->size; i++) {
    63     owl_list_append_element(l, g_strdup(d->els[i].k));
     59  for (i = 0; i < d->size; i++) {
     60    g_ptr_array_add(keys, g_strdup(d->els[i].k));
    6461  }
     62  return keys;
    6563}
    6664
     
    107105/* Doesn't free the value of the element, but does
    108106 * return it so the caller can free it. */
    109 void *owl_dict_remove_element(owl_dict *d, const char *k) {
     107CALLER_OWN void *owl_dict_remove_element(owl_dict *d, const char *k)
     108{
    110109  int i;
    111110  int pos, found;
Note: See TracChangeset for help on using the changeset viewer.