diff options
Diffstat (limited to 'src/data/map.c')
| -rw-r--r-- | src/data/map.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/data/map.c b/src/data/map.c index 7981356..4542d88 100644 --- a/src/data/map.c +++ b/src/data/map.c @@ -1,13 +1,13 @@ /*:* *: File: ./src/data/map.c *: A simple interpreter - *: + *: *: WWW : http://fype.buetow.org *: E-Mail : fype@dev.buetow.org - *: - *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow + *: + *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow *: All rights reserved. - *: + *: *: Redistribution and use in source and binary forms, with or without modi- *: fication, are permitted provided that the following conditions are met: *: * Redistributions of source code must retain the above copyright @@ -15,20 +15,20 @@ *: * Redistributions in binary form must reproduce the above copyright *: notice, this list of conditions and the following disclaimer in the *: documentation and/or other materials provided with the distribution. - *: * Neither the name of P. B. Labs nor the names of its contributors may - *: be used to endorse or promote products derived from this software + *: * Neither the name of P. B. Labs nor the names of its contributors may + *: be used to endorse or promote products derived from this software *: without specific prior written permission. - *: - *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR - *: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + *: + *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR + *: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT, - *: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - *: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - *: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT, + *: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + *: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + *: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - *: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - *: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + *: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + *: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *: POSSIBILITY OF SUCH DAMAGE. *:*/ @@ -36,7 +36,7 @@ Map* map_new(int i_max_size) { - return map_new_named(i_max_size, "noname"); + return (map_new_named(i_max_size, "noname")); } Map* @@ -55,29 +55,29 @@ map_new_named(int i_max_size, char *c_name) { p_map->i_size = 0; p_map->i_max_size = i_max_size; - return p_map; + return (p_map); } _Bool map_empty(Map *p_map) { - return p_map->i_size == 0; + return (p_map->i_size == 0); } _Bool map_full(Map *p_map) { - return p_map->i_size == p_map->i_max_size; + return (p_map->i_size == p_map->i_max_size); } int map_next_free_addr(Map *p_map) { for (int i = 0; i < p_map->i_max_size; ++i) if (p_map->pc_keys[i] == NULL) - return i; + return (i); ERROR("No free space left in the map (%s)", p_map->c_name); // This point should not be reached! - return 0; + return (0); } _Bool @@ -90,14 +90,14 @@ map_insert(Map *p_map, char *c_key, void *p_val) { p_map->pp_vals[i_free_addr] = p_val; ++p_map->i_size; - return true; + return (true); } _Bool map_insert2(Map *p_map, char *c_key1, char *c_key2, void *p_val) { char c_key[HASH_MKEYLEN]; sprintf(c_key, "%s%s%s", c_key1, SEP, c_key2); - return map_insert(p_map, c_key, p_val); + return (map_insert(p_map, c_key, p_val)); } _Bool @@ -105,11 +105,11 @@ map_insert_if_not_exists(Map *p_map, char *c_key, void *p_val) { void *p_void = map_get(p_map, c_key); if (p_void) - return false; + return (false); - return map_insert(p_map, c_key, p_val); + return (map_insert(p_map, c_key, p_val)); - return true; + return (true); } void @@ -130,33 +130,33 @@ map_remove(Map *p_map, char *c_key) { void* map_get(Map *p_map, char *c_key) { if (map_empty(p_map)) - return NULL; + return (NULL); int i_index = map_get_addr(p_map, c_key); - return i_index >= 0 ? p_map->pp_vals[i_index] : NULL; + return (i_index >= 0 ? p_map->pp_vals[i_index] : NULL); } void* map_get2(Map *p_map, char *c_key1, char *c_key2) { char c_key[HASH_MKEYLEN]; sprintf(c_key, "%s%s%s", c_key1, SEP, c_key2); - return map_get(p_map, c_key); + return (map_get(p_map, c_key)); } _Bool map_exists(Map *p_map, char *c_key) { if (map_empty(p_map)) - return false; + return (false); int i_index = map_get_addr(p_map, c_key); - return i_index >= 0 ? true : false; + return (i_index >= 0 ? true : false); } _Bool map_exists2(Map *p_map, char *c_key1, char *c_key2) { if (map_empty(p_map)) - return false; + return (false); char c_key[HASH_MKEYLEN]; sprintf(c_key, "%s%s%s:", c_key1, SEP, c_key2); @@ -168,25 +168,25 @@ map_exists2(Map *p_map, char *c_key1, char *c_key2) { char* map_get_key(Map *p_map, void *p_val) { if (map_empty(p_map)) - return NULL; + return (NULL); for (int i = 0; i < p_map->i_max_size; ++i) if ((unsigned) p_map->pp_vals[i] == (unsigned) p_val) - return p_map->pc_keys[i]; + return (p_map->pc_keys[i]); - return NULL; + return (NULL); } int map_get_addr(Map *p_map, char *c_key) { if (map_empty(p_map)) - return -1; + return (-1); for (int i = 0; i < p_map->i_max_size; ++i) if (p_map->pc_keys[i] != NULL && strcmp(p_map->pc_keys[i], c_key) == 0) - return i; + return (i); - return -1; + return (-1); } void |
