@@ -173,16 +173,16 @@ void *arena_alloc(arena_t *arena, int size)
173173 }
174174
175175 /* Align to sizeof(void*) bytes for host compatibility */
176- int alignment = sizeof (void * );
176+ const int alignment = sizeof (void * );
177177 size = (size + alignment - 1 ) & ~(alignment - 1 );
178178
179179 if (!arena -> head || arena -> head -> offset + size > arena -> head -> capacity ) {
180180 /* Need a new block: choose capacity = max(DEFAULT_ARENA_SIZE,
181181 * arena->block_size, size) */
182- int base =
182+ const int base =
183183 (arena -> block_size > DEFAULT_ARENA_SIZE ? arena -> block_size
184184 : DEFAULT_ARENA_SIZE );
185- int new_capacity = (size > base ? size : base );
185+ const int new_capacity = (size > base ? size : base );
186186 arena_block_t * new_block = arena_block_create (new_capacity );
187187 new_block -> next = arena -> head ;
188188 arena -> head = new_block ;
@@ -282,7 +282,7 @@ void *arena_realloc(arena_t *arena, char *oldptr, int oldsz, int newsz)
282282 */
283283char * arena_strdup (arena_t * arena , char * str )
284284{
285- int n = strlen (str );
285+ const int n = strlen (str );
286286 char * dup = arena_alloc (arena , n + 1 );
287287 memcpy (dup , str , n );
288288 dup [n ] = '\0' ;
@@ -368,14 +368,14 @@ void arena_free(arena_t *arena)
368368 */
369369int hashmap_hash_index (int size , char * key )
370370{
371- int hash = 0x811c9dc5 , mask ;
371+ int hash = 0x811c9dc5 ;
372372
373373 for (; * key ; key ++ ) {
374374 hash ^= * key ;
375375 hash *= 0x01000193 ;
376376 }
377377
378- mask = hash >> 31 ;
378+ const int mask = hash >> 31 ;
379379 return ((hash ^ mask ) - mask ) & (size - 1 );
380380}
381381
@@ -431,7 +431,7 @@ hashmap_node_t *hashmap_node_new(char *key, void *val)
431431 if (!key )
432432 return NULL ;
433433
434- int len = strlen (key );
434+ const int len = strlen (key );
435435 hashmap_node_t * node = arena_alloc (HASHMAP_ARENA , sizeof (hashmap_node_t ));
436436
437437
0 commit comments