@@ -33,7 +33,7 @@ typedef struct _nr_func_hashmap {
33
33
} nr_func_hashmap_t ;
34
34
35
35
static nr_func_hashmap_t * nr_func_hashmap_create_internal (size_t log2_num_buckets ) {
36
- nr_func_hashmap_t * hashmap ;
36
+ nr_func_hashmap_t * hashmap = NULL ;
37
37
38
38
if (0 == log2_num_buckets ) {
39
39
/*
@@ -68,8 +68,7 @@ static bool nr_func_hashmap_key_equals(nr_func_hashmap_key_t* a, nr_func_hashmap
68
68
}
69
69
70
70
static bool nr_func_hashmap_fetch_internal (nr_func_hashmap_t * hashmap , size_t hash , nr_func_hashmap_key_t * key , nr_func_bucket_t * * bucket_ptr ) {
71
- nr_func_bucket_t * bucket ;
72
- for (bucket = hashmap -> buckets [hash ]; bucket ; bucket = bucket -> next ) {
71
+ for (nr_func_bucket_t * bucket = hashmap -> buckets [hash ]; bucket ; bucket = bucket -> next ) {
73
72
if (nr_func_hashmap_key_equals (bucket -> key , key )) {
74
73
if (bucket_ptr ) {
75
74
* bucket_ptr = bucket ;
@@ -83,9 +82,8 @@ static bool nr_func_hashmap_fetch_internal(nr_func_hashmap_t* hashmap, size_t ha
83
82
static nruserfn_t * nr_func_hashmap_add_internal (nr_func_hashmap_t * hashmap ,
84
83
size_t hash_key ,
85
84
nr_func_hashmap_key_t * key ) {
86
- nr_func_bucket_t * bucket ;
85
+ nr_func_bucket_t * bucket = ( nr_func_bucket_t * ) nr_malloc ( sizeof ( nr_func_bucket_t )) ;
87
86
88
- bucket = (nr_func_bucket_t * )nr_malloc (sizeof (nr_func_bucket_t ));
89
87
bucket -> prev = NULL ;
90
88
bucket -> next = hashmap -> buckets [hash_key ];
91
89
bucket -> key = (nr_func_hashmap_key_t * )nr_malloc (sizeof (nr_func_hashmap_key_t ));
@@ -107,7 +105,7 @@ static nruserfn_t* nr_func_hashmap_add_internal(nr_func_hashmap_t* hashmap,
107
105
108
106
static nruserfn_t * nr_func_hashmap_lookup_internal (nr_func_hashmap_t * hashmap , nr_func_hashmap_key_t * key ) {
109
107
size_t hash ;
110
- nr_func_bucket_t * bucket ;
108
+ nr_func_bucket_t * bucket = NULL ;
111
109
112
110
if (nrunlikely ((NULL == hashmap ) || (NULL == key ))) {
113
111
return NULL ;
@@ -123,8 +121,8 @@ static nruserfn_t* nr_func_hashmap_lookup_internal(nr_func_hashmap_t* hashmap, n
123
121
124
122
static nruserfn_t * nr_func_hashmap_update_internal (nr_func_hashmap_t * hashmap , nr_func_hashmap_key_t * key , bool * created ) {
125
123
size_t hash ;
126
- nr_func_bucket_t * bucket ;
127
- nruserfn_t * wraprec ;
124
+ nr_func_bucket_t * bucket = NULL ;
125
+ nruserfn_t * wraprec = NULL ;
128
126
129
127
if (nrunlikely ((NULL == hashmap ) || (NULL == key ))) {
130
128
return NULL ;
@@ -156,7 +154,7 @@ static void nr_func_hashmap_destroy_bucket_internal(nr_func_bucket_t** bucket_pt
156
154
157
155
static void nr_func_hashmap_destroy_internal (nr_func_hashmap_t * * hashmap_ptr ) {
158
156
size_t count ;
159
- nr_func_hashmap_t * hashmap ;
157
+ nr_func_hashmap_t * hashmap = NULL ;
160
158
size_t i ;
161
159
162
160
if ((NULL == hashmap_ptr ) || (NULL == * hashmap_ptr )) {
@@ -204,7 +202,7 @@ typedef struct _nr_scope_hashmap {
204
202
} nr_scope_hashmap_t ;
205
203
206
204
static nr_scope_hashmap_t * nr_scope_hashmap_create_internal (size_t log2_num_buckets ) {
207
- nr_scope_hashmap_t * hashmap ;
205
+ nr_scope_hashmap_t * hashmap = NULL ;
208
206
209
207
if (0 == log2_num_buckets ) {
210
208
/*
@@ -239,8 +237,8 @@ static bool nr_scope_hashmap_key_equals(nr_scope_hashmap_key_t* a, nr_scope_hash
239
237
}
240
238
241
239
static bool nr_scope_hashmap_fetch_internal (nr_scope_hashmap_t * hashmap , size_t hash , nr_scope_hashmap_key_t * key , nr_scope_bucket_t * * bucket_ptr ) {
242
- nr_scope_bucket_t * bucket ;
243
- for (bucket = hashmap -> buckets [hash ]; bucket ; bucket = bucket -> next ) {
240
+
241
+ for (nr_scope_bucket_t * bucket = hashmap -> buckets [hash ]; bucket ; bucket = bucket -> next ) {
244
242
if (nr_scope_hashmap_key_equals (bucket -> key , key )) {
245
243
if (bucket_ptr ) {
246
244
* bucket_ptr = bucket ;
@@ -254,9 +252,7 @@ static bool nr_scope_hashmap_fetch_internal(nr_scope_hashmap_t* hashmap, size_t
254
252
static nr_func_hashmap_t * nr_scope_hashmap_add_internal (nr_scope_hashmap_t * hashmap ,
255
253
size_t hash_key ,
256
254
nr_scope_hashmap_key_t * key ) {
257
- nr_scope_bucket_t * bucket ;
258
-
259
- bucket = (nr_scope_bucket_t * )nr_malloc (sizeof (nr_scope_bucket_t ));
255
+ nr_scope_bucket_t * bucket = (nr_scope_bucket_t * )nr_malloc (sizeof (nr_scope_bucket_t ));
260
256
bucket -> prev = NULL ;
261
257
bucket -> next = hashmap -> buckets [hash_key ];
262
258
bucket -> key = (nr_scope_hashmap_key_t * )nr_malloc (sizeof (nr_scope_hashmap_key_t ));
@@ -277,7 +273,7 @@ static nr_func_hashmap_t* nr_scope_hashmap_add_internal(nr_scope_hashmap_t* hash
277
273
278
274
static nr_func_hashmap_t * nr_scope_hashmap_lookup_internal (nr_scope_hashmap_t * hashmap , nr_scope_hashmap_key_t * key ) {
279
275
size_t hash ;
280
- nr_scope_bucket_t * bucket ;
276
+ nr_scope_bucket_t * bucket = NULL ;
281
277
282
278
if (nrunlikely ((NULL == hashmap ) || (NULL == key ))) {
283
279
return NULL ;
@@ -293,7 +289,7 @@ static nr_func_hashmap_t* nr_scope_hashmap_lookup_internal(nr_scope_hashmap_t* h
293
289
294
290
static nr_func_hashmap_t * nr_scope_hashmap_update_internal (nr_scope_hashmap_t * hashmap , nr_scope_hashmap_key_t * key ) {
295
291
size_t hash ;
296
- nr_scope_bucket_t * bucket ;
292
+ nr_scope_bucket_t * bucket = NULL ;
297
293
298
294
if (nrunlikely ((NULL == hashmap ) || (NULL == key ))) {
299
295
return NULL ;
@@ -319,7 +315,7 @@ static void nr_scope_hashmap_destroy_bucket_internal(nr_scope_bucket_t** bucket_
319
315
320
316
static void nr_scope_hashmap_destroy_internal (nr_scope_hashmap_t * * hashmap_ptr ) {
321
317
size_t count ;
322
- nr_scope_hashmap_t * hashmap ;
318
+ nr_scope_hashmap_t * hashmap = NULL ;
323
319
size_t i ;
324
320
325
321
if ((NULL == hashmap_ptr ) || (NULL == * hashmap_ptr )) {
0 commit comments