Changeset 4eca056 in mainline for uspace/lib/c/generic/adt
- Timestamp:
- 2010-11-18T23:36:04Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aaa3f33a
- Parents:
- 88a1bb9
- Location:
- uspace/lib/c/generic/adt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/char_map.c
r88a1bb9 r4eca056 65 65 */ 66 66 static int 67 char_map_add_item(char_map_ refmap, const char *identifier, size_t length,67 char_map_add_item(char_map_t *map, const char *identifier, size_t length, 68 68 const int value) 69 69 { 70 70 if (map->next == (map->size - 1)) { 71 char_map_ ref*tmp;72 73 tmp = (char_map_ ref*) realloc(map->items,74 sizeof(char_map_ ref) * 2 * map->size);71 char_map_t **tmp; 72 73 tmp = (char_map_t **) realloc(map->items, 74 sizeof(char_map_t *) * 2 * map->size); 75 75 if (!tmp) 76 76 return ENOMEM; … … 80 80 } 81 81 82 map->items[map->next] = (char_map_ ref) malloc(sizeof(char_map_t));82 map->items[map->next] = (char_map_t *) malloc(sizeof(char_map_t)); 83 83 if (!map->items[map->next]) 84 84 return ENOMEM; … … 110 110 * @returns FALSE otherwise. 111 111 */ 112 static int char_map_is_valid(const char_map_ refmap)112 static int char_map_is_valid(const char_map_t *map) 113 113 { 114 114 return map && (map->magic == CHAR_MAP_MAGIC_VALUE); … … 139 139 */ 140 140 int 141 char_map_add(char_map_ refmap, const char *identifier, size_t length,141 char_map_add(char_map_t *map, const char *identifier, size_t length, 142 142 const int value) 143 143 { … … 172 172 * @param[in,out] map The character string to integer map. 173 173 */ 174 void char_map_destroy(char_map_ refmap)174 void char_map_destroy(char_map_t *map) 175 175 { 176 176 if (char_map_is_valid(map)) { … … 200 200 * @returns NULL if the key is not assigned a node. 201 201 */ 202 static char_map_ ref203 char_map_find_node(const char_map_ refmap, const char *identifier,202 static char_map_t * 203 char_map_find_node(const char_map_t *map, const char *identifier, 204 204 size_t length) 205 205 { … … 224 224 } 225 225 226 return map;226 return (char_map_t *) map; 227 227 } 228 228 … … 242 242 * @returns CHAR_MAP_NULL if the key is not assigned a value. 243 243 */ 244 int char_map_exclude(char_map_ refmap, const char *identifier, size_t length)245 { 246 char_map_ refnode;244 int char_map_exclude(char_map_t *map, const char *identifier, size_t length) 245 { 246 char_map_t *node; 247 247 248 248 node = char_map_find_node(map, identifier, length); … … 270 270 * @returns CHAR_MAP_NULL if the key is not assigned a value. 271 271 */ 272 int char_map_find(const char_map_ refmap, const char *identifier, size_t length)273 { 274 char_map_ refnode;272 int char_map_find(const char_map_t *map, const char *identifier, size_t length) 273 { 274 char_map_t *node; 275 275 276 276 node = char_map_find_node(map, identifier, length); … … 285 285 * @returns ENOMEM if there is not enough memory left. 286 286 */ 287 int char_map_initialize(char_map_ refmap)287 int char_map_initialize(char_map_t *map) 288 288 { 289 289 if (!map) … … 295 295 map->next = 0; 296 296 297 map->items = malloc(sizeof(char_map_ ref) * map->size);297 map->items = malloc(sizeof(char_map_t *) * map->size); 298 298 if (!map->items) { 299 299 map->magic = 0; … … 330 330 */ 331 331 int 332 char_map_update(char_map_ refmap, const char *identifier, const size_t length,332 char_map_update(char_map_t *map, const char *identifier, const size_t length, 333 333 const int value) 334 334 { 335 char_map_ refnode;335 char_map_t *node; 336 336 337 337 node = char_map_find_node(map, identifier, length); -
uspace/lib/c/generic/adt/dynamic_fifo.c
r88a1bb9 r4eca056 59 59 * @returns FALSE otherwise. 60 60 */ 61 static int dyn_fifo_is_valid(dyn_fifo_ reffifo)61 static int dyn_fifo_is_valid(dyn_fifo_t *fifo) 62 62 { 63 63 return fifo && (fifo->magic_value == DYN_FIFO_MAGIC_VALUE); … … 73 73 * @returns ENOMEM if there is not enough memory left. 74 74 */ 75 int dyn_fifo_initialize(dyn_fifo_ reffifo, int size)75 int dyn_fifo_initialize(dyn_fifo_t *fifo, int size) 76 76 { 77 77 if (!fifo) … … 104 104 * @returns ENOMEM if there is not enough memory left. 105 105 */ 106 int dyn_fifo_push(dyn_fifo_ reffifo, int value, int max_size)106 int dyn_fifo_push(dyn_fifo_t *fifo, int value, int max_size) 107 107 { 108 108 int *new_items; … … 154 154 * @returns ENOENT if the queue is empty. 155 155 */ 156 int dyn_fifo_pop(dyn_fifo_ reffifo)156 int dyn_fifo_pop(dyn_fifo_t *fifo) 157 157 { 158 158 int value; … … 176 176 * @returns ENOENT if the queue is empty. 177 177 */ 178 int dyn_fifo_value(dyn_fifo_ reffifo)178 int dyn_fifo_value(dyn_fifo_t *fifo) 179 179 { 180 180 if (!dyn_fifo_is_valid(fifo)) … … 193 193 * @returns EINVAL if the queue is not valid. 194 194 */ 195 int dyn_fifo_destroy(dyn_fifo_ reffifo)195 int dyn_fifo_destroy(dyn_fifo_t *fifo) 196 196 { 197 197 if (!dyn_fifo_is_valid(fifo)) -
uspace/lib/c/generic/adt/measured_strings.c
r88a1bb9 r4eca056 58 58 * @returns NULL if there is not enough memory left. 59 59 */ 60 measured_string_ ref60 measured_string_t * 61 61 measured_string_create_bulk(const char *string, size_t length) 62 62 { 63 measured_string_ refnew;63 measured_string_t *new; 64 64 65 65 if (length == 0) { … … 67 67 length++; 68 68 } 69 new = (measured_string_ ref) malloc(sizeof(measured_string_t) +69 new = (measured_string_t *) malloc(sizeof(measured_string_t) + 70 70 (sizeof(char) * (length + 1))); 71 71 if (!new) … … 88 88 * @returns NULL if there is not enough memory left. 89 89 */ 90 measured_string_ ref measured_string_copy(measured_string_refsource)91 { 92 measured_string_ refnew;90 measured_string_t *measured_string_copy(measured_string_t *source) 91 { 92 measured_string_t *new; 93 93 94 94 if (!source) 95 95 return NULL; 96 96 97 new = (measured_string_ ref) malloc(sizeof(measured_string_t));97 new = (measured_string_t *) malloc(sizeof(measured_string_t)); 98 98 if (new) { 99 99 new->value = (char *) malloc(source->length + 1); … … 131 131 */ 132 132 int 133 measured_strings_receive(measured_string_ ref*strings, char **data,133 measured_strings_receive(measured_string_t **strings, char **data, 134 134 size_t count) 135 135 { … … 166 166 (*data)[lengths[count] - 1] = '\0'; 167 167 168 *strings = (measured_string_ ref) malloc(sizeof(measured_string_t) *168 *strings = (measured_string_t *) malloc(sizeof(measured_string_t) * 169 169 count); 170 170 if (!*strings) { … … 212 212 * @returns NULL if there is not enough memory left. 213 213 */ 214 static size_t *prepare_lengths(const measured_string_ refstrings, size_t count)214 static size_t *prepare_lengths(const measured_string_t *strings, size_t count) 215 215 { 216 216 size_t *lengths; … … 248 248 * async_data_read_finalize() function. 249 249 */ 250 int measured_strings_reply(const measured_string_ refstrings, size_t count)250 int measured_strings_reply(const measured_string_t *strings, size_t count) 251 251 { 252 252 size_t *lengths; … … 311 311 */ 312 312 int 313 measured_strings_return(int phone, measured_string_ ref*strings, char **data,313 measured_strings_return(int phone, measured_string_t **strings, char **data, 314 314 size_t count) 315 315 { … … 339 339 } 340 340 341 *strings = (measured_string_ ref) malloc(sizeof(measured_string_t) *341 *strings = (measured_string_t *) malloc(sizeof(measured_string_t) * 342 342 count); 343 343 if (!*strings) { … … 385 385 */ 386 386 int 387 measured_strings_send(int phone, const measured_string_ refstrings,387 measured_strings_send(int phone, const measured_string_t *strings, 388 388 size_t count) 389 389 {
Note:
See TracChangeset
for help on using the changeset viewer.