Subversion Repositories HelenOS

Rev

Rev 3886 | Rev 4505 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3886 Rev 3912
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (c) 2008 Lukas Mejdrech
2
 * Copyright (c) 2009 Lukas Mejdrech
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
Line 77... Line 77...
77
    int index;                                                                  \
77
    int index;                                                                  \
78
                                                                                \
78
                                                                                \
79
    if( ! name##_is_valid( map )) return EINVAL;                                \
79
    if( ! name##_is_valid( map )) return EINVAL;                                \
80
    index = name##_items_add( & map->values, value );                           \
80
    index = name##_items_add( & map->values, value );                           \
81
    if( index < 0 ) return index;                                               \
81
    if( index < 0 ) return index;                                               \
82
    if( ERROR_OCCURED( char_map_add( & map->names, name, length, index ))){     \
82
    if( ERROR_OCCURRED( char_map_add( & map->names, name, length, index ))){        \
83
        name##_items_exclude_index( & map->values, index );                     \
83
        name##_items_exclude_index( & map->values, index );                     \
84
        return ERROR_CODE;                                                      \
84
        return ERROR_CODE;                                                      \
85
    }                                                                           \
85
    }                                                                           \
86
    return EOK;                                                                 \
86
    return EOK;                                                                 \
87
}                                                                               \
87
}                                                                               \
Line 119... Line 119...
119
    }                                                                           \
119
    }                                                                           \
120
    return NULL;                                                                \
120
    return NULL;                                                                \
121
}                                                                               \
121
}                                                                               \
122
                                                                                \
122
                                                                                \
123
int name##_initialize( name##_ref map ){                                        \
123
int name##_initialize( name##_ref map ){                                        \
-
 
124
    ERROR_DECLARE;                                                              \
-
 
125
                                                                                \
124
    if( ! map ) return EINVAL;                                                  \
126
    if( ! map ) return EINVAL;                                                  \
125
    char_map_initialize( & map->names );                                        \
127
    ERROR_PROPAGATE( char_map_initialize( & map->names ));                      \
126
    name##_items_initialize( & map->values );                                   \
128
    if( ERROR_OCCURRED( name##_items_initialize( & map->values ))){             \
-
 
129
        char_map_destroy( & map->names );                                       \
-
 
130
        return ERROR_CODE;                                                      \
-
 
131
    }                                                                           \
127
    map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE;                                  \
132
    map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE;                                  \
128
    return EOK;                                                                 \
133
    return EOK;                                                                 \
129
}                                                                               \
134
}                                                                               \
130
                                                                                \
135
                                                                                \
131
int name##_is_valid( name##_ref map ){                                          \
136
int name##_is_valid( name##_ref map ){                                          \