Changes in uspace/app/sbi/src/intmap.c [051b3db8:1ebc1a62] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/intmap.c
r051b3db8 r1ebc1a62 50 50 } 51 51 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 63 52 /** Set value corresponding to a key. 64 53 * … … 67 56 * is removed from the map. 68 57 * 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. 72 61 */ 73 62 void intmap_set(intmap_t *intmap, int key, void *value) … … 86 75 /* Remove map element. */ 87 76 list_remove(&intmap->elem, node); 88 free(elem); 77 node->data = NULL; 78 free(node); 89 79 } 90 80 return; … … 108 98 /** Get value corresponding to a key. 109 99 * 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. 112 102 * 113 103 * @return Value correspoding to @a key or @c NULL if no mapping … … 131 121 return NULL; 132 122 } 133 134 /** Get first element in the map.135 *136 * For iterating over the map, this returns the first element (in no137 * particular order).138 *139 * @param intmap Map140 * @return Map element or NULL if the map is empty141 */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 element158 * @return Key159 */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 element170 * @return Value171 */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.