Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/intmap.c

    r051b3db8 r1ebc1a62  
    5050}
    5151
    52 /** Deinitialize map.
    53  *
    54  * The map must be already empty.
    55  *
    56  * @param intmap        Map to initialize.
    57  */
    58 void intmap_fini(intmap_t *intmap)
    59 {
    60         list_fini(&intmap->elem);
    61 }
    62 
    6352/** Set value corresponding to a key.
    6453 *
     
    6756 * is removed from the map.
    6857 *
    69  * @param intmap        Map
    70  * @param key           Key (integer)
    71  * @param value         Value (must be a pointer) or @c NULL
     58 * @param intmap        Map.
     59 * @param key           Key (integer).
     60 * @param value         Value (must be a pointer) or @c NULL.
    7261 */
    7362void intmap_set(intmap_t *intmap, int key, void *value)
     
    8675                                /* Remove map element. */
    8776                                list_remove(&intmap->elem, node);
    88                                 free(elem);
     77                                node->data = NULL;
     78                                free(node);
    8979                        }
    9080                        return;
     
    10898/** Get value corresponding to a key.
    10999 *
    110  * @param intmap        Map
    111  * @param key           Key for which to retrieve mapping
     100 * @param intmap        Map.
     101 * @param key           Key for which to retrieve mapping.
    112102 *
    113103 * @return              Value correspoding to @a key or @c NULL if no mapping
     
    131121        return NULL;
    132122}
    133 
    134 /** Get first element in the map.
    135  *
    136  * For iterating over the map, this returns the first element (in no
    137  * particular order).
    138  *
    139  * @param intmap        Map
    140  * @return              Map element or NULL if the map is empty
    141  */
    142 map_elem_t *intmap_first(intmap_t *intmap)
    143 {
    144         list_node_t *node;
    145 
    146         node = list_first(&intmap->elem);
    147         if (node == NULL)
    148                 return NULL;
    149 
    150         return list_node_data(node, map_elem_t *);
    151 }
    152 
    153 /** Get element key.
    154  *
    155  * Giver a map element, return the key.
    156  *
    157  * @param elem          Map element
    158  * @return              Key
    159  */
    160 int intmap_elem_get_key(map_elem_t *elem)
    161 {
    162         return elem->key;
    163 }
    164 
    165 /** Get element value.
    166  *
    167  * Giver a map element, return the value.
    168  *
    169  * @param elem          Map element
    170  * @return              Value
    171  */
    172 void *intmap_elem_get_value(map_elem_t *elem)
    173 {
    174         return elem->value;
    175 }
Note: See TracChangeset for help on using the changeset viewer.