From af5dd76bca996577262e447fd8bff1bd0df30db7 Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 26 Oct 2005 08:29:38 +0000 Subject: 2005-10-26 Martin Hunt * map.c (_new_map_create, _new_map_del_node, _new_map_del_node, _new_map_set_int64, _new_map_set_str,_new_map_get_int64, _new_map_get_str, _new_map_get_stat, _new_map_set_stat): New internal functions for the new API. * map-int.c (__stp_map_set_int64): Modify to return an error code. * map-stat.c (_stp_map_add_stat): Ditto. * map-str (_stp_map_set_str): Ditto. * Doxyfile: Remove predefines NEED_STRING_VALS, NEED_STATS, NEED_INT64. * map-keys.c: Ditto. * list.c (_stp_list_new): Ditto. Also set map->list. * map-values.c: Ditto. --- runtime/map-values.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'runtime/map-values.c') diff --git a/runtime/map-values.c b/runtime/map-values.c index 638b3e23..743323e4 100644 --- a/runtime/map-values.c +++ b/runtime/map-values.c @@ -6,25 +6,10 @@ */ #include "map.h" - -#if !defined(NEED_STRING_VALS) && !defined(NEED_INT64_VALS) && !defined(NEED_STAT_VALS) -#error Need to define at least one of NEED_STRING_VALS, NEED_INT64_VALS and NEED_STAT_VALS -#endif - -#ifdef NEED_STRING_VALS #include "map-str.c" -#endif - -#ifdef NEED_STAT_VALS #include "map-stat.c" -#endif - -#ifdef NEED_INT64_VALS #include "map-int.c" -#endif - -#if defined(NEED_INT64_VALS) || defined (NEED_STAT_VALS) /** Adds an int64 to the current element's value. * This adds an int64 to the current element's value. The map must have been created * to hold int64s or stats. @@ -33,23 +18,23 @@ * is set for the map, this function does nothing. * @param map * @param val value + * @returns \li \c 0 on success \li \c -1 on overflow \li \c -2 on bad map or key * @ingroup map_set */ -void _stp_map_add_int64 (MAP map, int64_t val) +int _stp_map_add_int64 (MAP map, int64_t val) { if (map == NULL) - return; + return -2; -#ifdef NEED_INT64_VALS if (map->type == INT64) - __stp_map_set_int64 (map, val, 1); -#endif -#ifdef NEED_STAT_VALS + return __stp_map_set_int64 (map, val, 1); + if (map->type == STAT) - _stp_map_add_stat (map, val); -#endif + return _stp_map_add_stat (map, val); + + /* shouldn't get here */ + return -2; } -#endif unsigned _stp_map_entry_exists (MAP map) { -- cgit