17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#import "runtime.h"
#import "runtime-private.h"
uint32_t
objc_hash_string(const char *str)
{
uint32_t hash = 0;
|
<
<
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#import "runtime.h"
#import "runtime-private.h"
uint32_t
objc_hash_string(const char *str)
{
uint32_t hash = 0;
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
static void
insert(struct objc_hashtable *h, const char *key, const void *obj)
{
uint32_t i, hash, last;
struct objc_hashtable_bucket *bucket;
hash = objc_hash_string(key);
assert(h->count + 1 <= UINT32_MAX / 4);
if ((h->count + 1) * 4 / (h->last_idx + 1) >= 3) {
struct objc_hashtable_bucket **ndata;
uint32_t nsize = (h->last_idx + 1) * 2;
assert(nsize > 0);
ndata = malloc(nsize * sizeof(struct objc_hashtable_bucket*));
if (ndata == NULL)
OBJC_ERROR("Not enough memory to insert into hash "
"table!");
for (i = 0; i < nsize; i++)
|
>
|
>
|
>
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
static void
insert(struct objc_hashtable *h, const char *key, const void *obj)
{
uint32_t i, hash, last;
struct objc_hashtable_bucket *bucket;
hash = objc_hash_string(key);
if (h->count + 1 > UINT32_MAX / 4)
OBJC_ERROR("Integer overflow!");
if ((h->count + 1) * 4 / (h->last_idx + 1) >= 3) {
struct objc_hashtable_bucket **ndata;
uint32_t nsize = (h->last_idx + 1) * 2;
if (nsize == 0)
OBJC_ERROR("Integer overflow!");
ndata = malloc(nsize * sizeof(struct objc_hashtable_bucket*));
if (ndata == NULL)
OBJC_ERROR("Not enough memory to insert into hash "
"table!");
for (i = 0; i < nsize; i++)
|