diff options
author | hunt <hunt> | 2007-01-10 15:07:25 +0000 |
---|---|---|
committer | hunt <hunt> | 2007-01-10 15:07:25 +0000 |
commit | 3c2a749a7ef6df845063867ff69b12276ba09800 (patch) | |
tree | 76ccc779ffa9e250d0f6995594677ba8144f1ec2 /runtime/map-gen.c | |
parent | 4f723326777390f7ac0b949046e4adbf67a3f3cd (diff) | |
download | systemtap-steved-3c2a749a7ef6df845063867ff69b12276ba09800.tar.gz systemtap-steved-3c2a749a7ef6df845063867ff69b12276ba09800.tar.xz systemtap-steved-3c2a749a7ef6df845063867ff69b12276ba09800.zip |
2007-01-10 Martin Hunt <hunt@redhat.com>
PR 3708
* map.c (str_copy): Check for NULL pointers.
(_new_map_set_int64): Don't check val for 0.
(_new_map_set_str): Don't check val for NULL.
* map-gen.c (VAL_IS_ZERO): Removed.
(_stp_map_del): New.
(__stp_map_set): Don't check for zero.
* pmap-gen.c (VAL_IS_ZERO): Removed.
(_stp_pmap_del): New.
(__stp_pmap_set): Don't check for zero.
Diffstat (limited to 'runtime/map-gen.c')
-rw-r--r-- | runtime/map-gen.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/runtime/map-gen.c b/runtime/map-gen.c index 66654913..f2b39d40 100644 --- a/runtime/map-gen.c +++ b/runtime/map-gen.c @@ -40,7 +40,6 @@ #define VALN s #define MAP_SET_VAL(a,b,c,d) _new_map_set_str(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_str(n) -#define VAL_IS_ZERO(val,add) (val == 0 || *val == 0) #define NULLRET "" #elif VALUE_TYPE == INT64 #define VALTYPE int64_t @@ -49,7 +48,6 @@ #define VALN i #define MAP_SET_VAL(a,b,c,d) _new_map_set_int64(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_int64(n) -#define VAL_IS_ZERO(val,add) (val == 0) #define NULLRET (int64_t)0 #elif VALUE_TYPE == STAT #define VALTYPE stat* @@ -58,7 +56,6 @@ #define VALN x #define MAP_SET_VAL(a,b,c,d) _new_map_set_stat(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_stat(n) -#define VAL_IS_ZERO(val,add) (val == 0 && !add) #define NULLRET (stat*)0 #else #error Need to define VALUE_TYPE as STRING, STAT, or INT64 @@ -429,19 +426,11 @@ int KEYSYM(__stp_map_set) (MAP map, ALLKEYSD(key), VSTYPE val, int add) #endif #endif ) { - if VAL_IS_ZERO(val,add) { - if (!add) - _new_map_del_node(map,(struct map_node *)n); - return 0; - - } return MAP_SET_VAL(map,(struct map_node *)n, val, add); } } /* key not found */ dbug("key not found\n"); - if VAL_IS_ZERO(val,add) - return 0; n = (struct KEYSYM(map_node)*)_new_map_create (map, head); if (n == NULL) @@ -498,6 +487,43 @@ VALTYPE KEYSYM(_stp_map_get) (MAP map, ALLKEYSD(key)) return NULLRET; } +int KEYSYM(_stp_map_del) (MAP map, ALLKEYSD(key)) +{ + unsigned int hv; + struct hlist_head *head; + struct hlist_node *e; + struct KEYSYM(map_node) *n; + + if (map == NULL) + return -1; + + hv = KEYSYM(hash) (ALLKEYS(key)); + head = &map->hashes[hv]; + + hlist_for_each(e, head) { + n = (struct KEYSYM(map_node) *)((long)e - sizeof(struct list_head)); + if (KEY1_EQ_P(n->key1, key1) +#if KEY_ARITY > 1 + && KEY2_EQ_P(n->key2, key2) +#if KEY_ARITY > 2 + && KEY3_EQ_P(n->key3, key3) +#if KEY_ARITY > 3 + && KEY4_EQ_P(n->key4, key4) +#if KEY_ARITY > 4 + && KEY5_EQ_P(n->key5, key5) +#endif +#endif +#endif +#endif + ) { + _new_map_del_node(map,(struct map_node *)n); + return 0; + } + } + /* key not found */ + return 0; +} + #undef KEY1NAME #undef KEY1N @@ -548,5 +574,4 @@ VALTYPE KEYSYM(_stp_map_get) (MAP map, ALLKEYSD(key)) #undef MAP_SET_VAL #undef MAP_GET_VAL -#undef VAL_IS_ZERO #undef NULLRET |