CoreFW  Diff

Differences From Artifact [33cb49edea]:

To Artifact [415ab5e653]:


26
27
28
29
30
31
32

33
34
35
36
37
38
39
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+








#include <stdlib.h>
#include <stdint.h>
#include <string.h>

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

struct CFWString {
	CFWObject obj;
	char *data;
	size_t len;
};

78
79
80
81
82
83
84

















85
86
87
88
89
90
91
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	str2 = ptr2;

	if (str1->len != str2->len)
		return false;

	return !memcmp(str1->data, str2->data, str1->len);
}

static uint32_t
hash(void *ptr)
{
	CFWString *str = ptr;
	size_t i;
	uint32_t hash;

	CFW_HASH_INIT(hash);

	for (i = 0; i < str->len; i++)
		CFW_HASH_ADD(hash, str->data[i]);

	CFW_HASH_FINALIZE(hash);

	return hash;
}

static void*
copy(void *ptr)
{
	CFWString *str = ptr;
	CFWString *new;

173
174
175
176
177
178
179

180
181
182
191
192
193
194
195
196
197
198
199
200
201







+




static CFWClass class = {
	.name = "CFWString",
	.size = sizeof(CFWString),
	.ctor = ctor,
	.dtor = dtor,
	.equal = equal,
	.hash = hash,
	.copy = copy
};
CFWClass *cfw_string = &class;