ObjFW  Diff

Differences From Artifact [49bc1623d2]:

To Artifact [bbd4fbe6f2]:


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifdef OF_SELUID24
static struct objc_dtable_level3 *empty_level3 = NULL;
#endif

static void
init(void)
{
	uint_fast16_t i;

	empty_level2 = malloc(sizeof(struct objc_dtable_level2));
	if (empty_level2 == NULL)
		OBJC_ERROR("Not enough memory to allocate dtable!");

#ifdef OF_SELUID24
	empty_level3 = malloc(sizeof(struct objc_dtable_level3));







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifdef OF_SELUID24
static struct objc_dtable_level3 *empty_level3 = NULL;
#endif

static void
init(void)
{
	uint16_t i;

	empty_level2 = malloc(sizeof(struct objc_dtable_level2));
	if (empty_level2 == NULL)
		OBJC_ERROR("Not enough memory to allocate dtable!");

#ifdef OF_SELUID24
	empty_level3 = malloc(sizeof(struct objc_dtable_level3));
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#endif
}

struct objc_dtable*
objc_dtable_new(void)
{
	struct objc_dtable *dtable;
	uint_fast16_t i;

#ifdef OF_SELUID24
	if (empty_level2 == NULL || empty_level3 == NULL)
		init();
#else
	if (empty_level2 == NULL)
		init();







|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#endif
}

struct objc_dtable*
objc_dtable_new(void)
{
	struct objc_dtable *dtable;
	uint16_t i;

#ifdef OF_SELUID24
	if (empty_level2 == NULL || empty_level3 == NULL)
		init();
#else
	if (empty_level2 == NULL)
		init();
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

	return dtable;
}

void
objc_dtable_copy(struct objc_dtable *dst, struct objc_dtable *src)
{
	uint_fast16_t i, j;
#ifdef OF_SELUID24
	uint_fast16_t k;
#endif
	uint32_t idx;

	for (i = 0; i < 256; i++) {
		if (src->buckets[i] == empty_level2)
			continue;








|

|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

	return dtable;
}

void
objc_dtable_copy(struct objc_dtable *dst, struct objc_dtable *src)
{
	uint16_t i, j;
#ifdef OF_SELUID24
	uint16_t k;
#endif
	uint32_t idx;

	for (i = 0; i < 256; i++) {
		if (src->buckets[i] == empty_level2)
			continue;

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#else
	uint8_t i = idx >> 8;
	uint8_t j = idx;
#endif

	if (dtable->buckets[i] == empty_level2) {
		struct objc_dtable_level2 *level2;
		uint_fast16_t l;

		level2 = malloc(sizeof(struct objc_dtable_level2));

		if (level2 == NULL)
			OBJC_ERROR("Not enough memory to insert into dtable!");

		for (l = 0; l < 256; l++)
#ifdef OF_SELUID24
			level2->buckets[l] = empty_level3;
#else
			level2->buckets[l] = (IMP)0;
#endif

		dtable->buckets[i] = level2;
	}

#ifdef OF_SELUID24
	if (dtable->buckets[i]->buckets[j] == empty_level3) {
		struct objc_dtable_level3 *level3;
		uint_fast16_t l;

		level3 = malloc(sizeof(struct objc_dtable_level3));

		if (level3 == NULL)
			OBJC_ERROR("Not enough memory to insert into dtable!");

		for (l = 0; l < 256; l++)







|



















|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#else
	uint8_t i = idx >> 8;
	uint8_t j = idx;
#endif

	if (dtable->buckets[i] == empty_level2) {
		struct objc_dtable_level2 *level2;
		uint16_t l;

		level2 = malloc(sizeof(struct objc_dtable_level2));

		if (level2 == NULL)
			OBJC_ERROR("Not enough memory to insert into dtable!");

		for (l = 0; l < 256; l++)
#ifdef OF_SELUID24
			level2->buckets[l] = empty_level3;
#else
			level2->buckets[l] = (IMP)0;
#endif

		dtable->buckets[i] = level2;
	}

#ifdef OF_SELUID24
	if (dtable->buckets[i]->buckets[j] == empty_level3) {
		struct objc_dtable_level3 *level3;
		uint16_t l;

		level3 = malloc(sizeof(struct objc_dtable_level3));

		if (level3 == NULL)
			OBJC_ERROR("Not enough memory to insert into dtable!");

		for (l = 0; l < 256; l++)
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
	dtable->buckets[i]->buckets[j] = obj;
#endif
}

void
objc_dtable_free(struct objc_dtable *dtable)
{
	uint_fast16_t i;
#ifdef OF_SELUID24
	uint_fast16_t j;
#endif

	for (i = 0; i < 256; i++) {
		if (dtable->buckets[i] == empty_level2)
			continue;

#ifdef OF_SELUID24







|

|







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
	dtable->buckets[i]->buckets[j] = obj;
#endif
}

void
objc_dtable_free(struct objc_dtable *dtable)
{
	uint16_t i;
#ifdef OF_SELUID24
	uint16_t j;
#endif

	for (i = 0; i < 256; i++) {
		if (dtable->buckets[i] == empty_level2)
			continue;

#ifdef OF_SELUID24