Changeset 32eceb4f in mainline for uspace/lib/c/generic/adt/char_map.c


Ignore:
Timestamp:
2010-11-20T22:30:36Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cb59f787
Parents:
1b22bd4 (diff), 7e1f9b7 (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/char_map.c

    r1b22bd4 r32eceb4f  
    6060 * @param[in] value     The integral value to be stored for the key character
    6161 *                      string.
    62  * @returns             EOK on success.
    63  * @returns             ENOMEM if there is not enough memory left.
    64  * @returns             EEXIST if the key character string is already used.
     62 * @return              EOK on success.
     63 * @return              ENOMEM if there is not enough memory left.
     64 * @return              EEXIST if the key character string is already used.
    6565 */
    6666static int
    67 char_map_add_item(char_map_ref map, const char *identifier, size_t length,
     67char_map_add_item(char_map_t *map, const char *identifier, size_t length,
    6868    const int value)
    6969{
    7070        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);
    7575                if (!tmp)
    7676                        return ENOMEM;
     
    8080        }
    8181
    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));
    8383        if (!map->items[map->next])
    8484                return ENOMEM;
     
    107107 *
    108108 * @param[in] map       The character string to integer map.
    109  * @returns             TRUE if the map is valid.
    110  * @returns             FALSE otherwise.
    111  */
    112 static int char_map_is_valid(const char_map_ref map)
     109 * @return              TRUE if the map is valid.
     110 * @return              FALSE otherwise.
     111 */
     112static int char_map_is_valid(const char_map_t *map)
    113113{
    114114        return map && (map->magic == CHAR_MAP_MAGIC_VALUE);
     
    127127 * @param[in] value     The integral value to be stored for the key character
    128128 *                      string.
    129  * @returns             EOK on success.
    130  * @returns             EINVAL if the map is not valid.
    131  * @returns             EINVAL if the identifier parameter is NULL.
    132  * @returns             EINVAL if the length parameter zero (0) and the
     129 * @return              EOK on success.
     130 * @return              EINVAL if the map is not valid.
     131 * @return              EINVAL if the identifier parameter is NULL.
     132 * @return              EINVAL if the length parameter zero (0) and the
    133133 *                      identifier parameter is an empty character string (the
    134134 *                      first character is the terminating zero ('\0')
    135135 *                      character.
    136  * @returns             EEXIST if the key character string is already used.
    137  * @returns             Other error codes as defined for the
     136 * @return              EEXIST if the key character string is already used.
     137 * @return              Other error codes as defined for the
    138138 *                      char_map_add_item() function.
    139139 */
    140140int
    141 char_map_add(char_map_ref map, const char *identifier, size_t length,
     141char_map_add(char_map_t *map, const char *identifier, size_t length,
    142142    const int value)
    143143{
     
    172172 * @param[in,out] map   The character string to integer map.
    173173 */
    174 void char_map_destroy(char_map_ref map)
     174void char_map_destroy(char_map_t *map)
    175175{
    176176        if (char_map_is_valid(map)) {
     
    196196 *                      zero (0) which means that the string is processed until
    197197 *                      the terminating zero ('\0') character is found.
    198  * @returns             The node holding the integral value assigned to the key
     198 * @return              The node holding the integral value assigned to the key
    199199 *                      character string.
    200  * @returns             NULL if the key is not assigned a node.
    201  */
    202 static char_map_ref
    203 char_map_find_node(const char_map_ref map, const char *identifier,
     200 * @return              NULL if the key is not assigned a node.
     201 */
     202static char_map_t *
     203char_map_find_node(const char_map_t *map, const char *identifier,
    204204    size_t length)
    205205{
     
    224224        }
    225225
    226         return map;
     226        return (char_map_t *) map;
    227227}
    228228
     
    239239 *                      zero (0) which means that the string is processed until
    240240 *                      the terminating zero ('\0') character is found.
    241  * @returns             The integral value assigned to the key character string.
    242  * @returns             CHAR_MAP_NULL if the key is not assigned a value.
    243  */
    244 int char_map_exclude(char_map_ref map, const char *identifier, size_t length)
    245 {
    246         char_map_ref node;
     241 * @return              The integral value assigned to the key character string.
     242 * @return              CHAR_MAP_NULL if the key is not assigned a value.
     243 */
     244int char_map_exclude(char_map_t *map, const char *identifier, size_t length)
     245{
     246        char_map_t *node;
    247247
    248248        node = char_map_find_node(map, identifier, length);
     
    267267 *                      zero (0) which means that the string is processed until
    268268 *                      the terminating zero ('\0') character is found.
    269  *  @returns            The integral value assigned to the key character string.
    270  *  @returns            CHAR_MAP_NULL if the key is not assigned a value.
    271  */
    272 int char_map_find(const char_map_ref map, const char *identifier, size_t length)
    273 {
    274         char_map_ref node;
     269 *  @return             The integral value assigned to the key character string.
     270 *  @return             CHAR_MAP_NULL if the key is not assigned a value.
     271 */
     272int char_map_find(const char_map_t *map, const char *identifier, size_t length)
     273{
     274        char_map_t *node;
    275275
    276276        node = char_map_find_node(map, identifier, length);
     
    281281 *
    282282 *  @param[in,out] map  The character string to integer map.
    283  *  @returns            EOK on success.
    284  *  @returns            EINVAL if the map parameter is NULL.
    285  *  @returns            ENOMEM if there is not enough memory left.
    286  */
    287 int char_map_initialize(char_map_ref map)
     283 *  @return             EOK on success.
     284 *  @return             EINVAL if the map parameter is NULL.
     285 *  @return             ENOMEM if there is not enough memory left.
     286 */
     287int char_map_initialize(char_map_t *map)
    288288{
    289289        if (!map)
     
    295295        map->next = 0;
    296296
    297         map->items = malloc(sizeof(char_map_ref) * map->size);
     297        map->items = malloc(sizeof(char_map_t *) * map->size);
    298298        if (!map->items) {
    299299                map->magic = 0;
     
    319319 *  @param[in] value    The integral value to be stored for the key character
    320320 *                      string.
    321  *  @returns            EOK on success.
    322  *  @returns            EINVAL if the map is not valid.
    323  *  @returns            EINVAL if the identifier parameter is NULL.
    324  *  @returns            EINVAL if the length parameter zero (0) and the
     321 *  @return             EOK on success.
     322 *  @return             EINVAL if the map is not valid.
     323 *  @return             EINVAL if the identifier parameter is NULL.
     324 *  @return             EINVAL if the length parameter zero (0) and the
    325325 *                      identifier parameter is an empty character string (the
    326326 *                      first character is the terminating zero ('\0) character.
    327  *  @returns            EEXIST if the key character string is already used.
    328  *  @returns            Other error codes as defined for the char_map_add_item()
     327 *  @return             EEXIST if the key character string is already used.
     328 *  @return             Other error codes as defined for the char_map_add_item()
    329329 *                      function.
    330330 */
    331331int
    332 char_map_update(char_map_ref map, const char *identifier, const size_t length,
     332char_map_update(char_map_t *map, const char *identifier, const size_t length,
    333333    const int value)
    334334{
    335         char_map_ref node;
     335        char_map_t *node;
    336336
    337337        node = char_map_find_node(map, identifier, length);
Note: See TracChangeset for help on using the changeset viewer.