CoreFW  Diff

Differences From Artifact [30449aad8d]:

To Artifact [6c8dd7f75d]:


25
26
27
28
29
30
31

32
33
34
35
36
37
38
 */

#include <stdlib.h>

#include "object.h"
#include "map.h"
#include "hash.h"


static struct bucket {
	CFWObject *key, *obj;
	uint32_t hash;
} deleted = { NULL, NULL, 0 };

struct CFWMap {







>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 */

#include <stdlib.h>

#include "object.h"
#include "map.h"
#include "hash.h"
#include "string.h"

static struct bucket {
	CFWObject *key, *obj;
	uint32_t hash;
} deleted = { NULL, NULL, 0 };

struct CFWMap {
247
248
249
250
251
252
253
















254
255
256
257
258
259
260

		if (cfw_equal(map->data[i]->key, key))
			return map->data[i]->obj;
	}

	return NULL;
}

















bool
cfw_map_set(CFWMap *map, void *key, void *obj)
{
	uint32_t i, hash, last;

	if (key == NULL)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277

		if (cfw_equal(map->data[i]->key, key))
			return map->data[i]->obj;
	}

	return NULL;
}

void*
cfw_map_get_c(CFWMap *map, const char *key)
{
	CFWString *str;
	void *ret;

	if ((str = cfw_new(cfw_string, key)) == NULL)
		return NULL;

	ret = cfw_map_get(map, str);

	cfw_unref(str);

	return ret;
}

bool
cfw_map_set(CFWMap *map, void *key, void *obj)
{
	uint32_t i, hash, last;

	if (key == NULL)
351
352
353
354
355
356
357
















358
359
360
361
362
363
364

		if (!resize(map, map->items))
			return false;
	}

	return true;
}

















void
cfw_map_iter(CFWMap *map, cfw_map_iter_t *iter)
{
	iter->_map = map;
	iter->_pos = 0;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397

		if (!resize(map, map->items))
			return false;
	}

	return true;
}

bool
cfw_map_set_c(CFWMap *map, const char *key, void *obj)
{
	CFWString *str;
	bool ret;

	if ((str = cfw_new(cfw_string, key)) == NULL)
		return false;

	ret = cfw_map_set(map, str, obj);

	cfw_unref(str);

	return ret;
}

void
cfw_map_iter(CFWMap *map, cfw_map_iter_t *iter)
{
	iter->_map = map;
	iter->_pos = 0;