Changeset 4611094f in mainline for uspace/app/sbi/src/intmap.c
- Timestamp:
- 2011-03-20T19:09:19Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cfbcd86
- Parents:
- 8c76c30 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/intmap.c
r8c76c30 r4611094f 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 52 63 /** Set value corresponding to a key. 53 64 * … … 56 67 * is removed from the map. 57 68 * 58 * @param intmap Map .59 * @param key Key (integer) .60 * @param value Value (must be a pointer) or @c NULL .69 * @param intmap Map 70 * @param key Key (integer) 71 * @param value Value (must be a pointer) or @c NULL 61 72 */ 62 73 void intmap_set(intmap_t *intmap, int key, void *value) … … 75 86 /* Remove map element. */ 76 87 list_remove(&intmap->elem, node); 77 node->data = NULL; 78 free(node); 88 free(elem); 79 89 } 80 90 return; … … 98 108 /** Get value corresponding to a key. 99 109 * 100 * @param intmap Map .101 * @param key Key for which to retrieve mapping .110 * @param intmap Map 111 * @param key Key for which to retrieve mapping 102 112 * 103 113 * @return Value correspoding to @a key or @c NULL if no mapping … … 121 131 return NULL; 122 132 } 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.