ObjFW  Diff

Differences From Artifact [17553b85c5]:

To Artifact [2d5c8a5504]:

  • File src/OFXMLFactory.m — part of check-in [033054ad75] at 2009-05-29 19:21:57 on branch trunk — A few renames.

    OFExceptions:
    * OFNoMemException to OFOutOfMemoryException.
    * OFMemNotPartOfObjException to OFMemoryNotPartOfObjectException.

    OFObject:
    * -[addItemToMemoryPool:] to -[addMemoryToPool:].
    * -[allocWithSize:] to -[allocMemoryWithSize:].
    * -[allocNItems:withSize] to -[allocMemoryForNItems:withSize:].
    * -[resizeMem:toSize] to -[resizeMemory:toSize:].
    * -[resizeMem:toNItems:withSize:] to
    -[resizeMemoryToNItems:withSize:].
    * -[freeMem] to -[freeMemory:].

    OFString:
    * -[urlencode] to -[urlEncodedString].
    * -[urldecode] to -[urlDecodedString]. (user: js, size: 5323) [annotate] [blame] [check-ins using]


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
		@throw [OFOutOfRangeException newWithClass: class];
	len2 = *len + add;

	if ((str2 = realloc(*str, len2)) == NULL) {
		if (*str)
			free(*str);
		*str = NULL;
		@throw [OFNoMemException newWithClass: class
					      andSize: len2];
	}

	*str = str2;
	*len = len2;
}

static inline void







|
|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
		@throw [OFOutOfRangeException newWithClass: class];
	len2 = *len + add;

	if ((str2 = realloc(*str, len2)) == NULL) {
		if (*str)
			free(*str);
		*str = NULL;
		@throw [OFOutOfMemoryException newWithClass: class
						    andSize: len2];
	}

	*str = str2;
	*len = len2;
}

static inline void
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

	len = strlen(s);
	if (SIZE_MAX - len < 1)
		@throw [OFOutOfRangeException newWithClass: self];

	len++;
	if ((ret = malloc(len)) == NULL)
		@throw [OFNoMemException newWithClass: self
					      andSize: len];

	@try {
		for (i = 0; *s; s++) {
			switch (*s) {
				case '<':
					append(&ret, &len, &i, "&lt;", self);
					break;







|
|







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

	len = strlen(s);
	if (SIZE_MAX - len < 1)
		@throw [OFOutOfRangeException newWithClass: self];

	len++;
	if ((ret = malloc(len)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: self
						    andSize: len];

	@try {
		for (i = 0; *s; s++) {
			switch (*s) {
				case '<':
					append(&ret, &len, &i, "&lt;", self);
					break;
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
	/* Start of tag */
	len = strlen(name);
	if (SIZE_MAX - len < 3)
		@throw [OFOutOfRangeException newWithClass: self];
	len += 3;

	if ((xml = malloc(len)) == NULL)
		@throw [OFNoMemException newWithClass: self
					      andSize: len];

	i = 0;
	xml[i++] = '<';
	memcpy(xml + i, name, strlen(name));
	i += strlen(name);

	@try {







|
|







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
	/* Start of tag */
	len = strlen(name);
	if (SIZE_MAX - len < 3)
		@throw [OFOutOfRangeException newWithClass: self];
	len += 3;

	if ((xml = malloc(len)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: self
						    andSize: len];

	i = 0;
	xml[i++] = '<';
	memcpy(xml + i, name, strlen(name));
	i += strlen(name);

	@try {
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261

	len = strlen(*strs);
	if (SIZE_MAX - len < 1)
		@throw [OFOutOfRangeException newWithClass: self];
	len++;

	if ((ret = malloc(len)) == NULL)
		@throw [OFNoMemException newWithClass: self
					      andSize: len];

	memcpy(ret, strs[0], len - 1);
	pos = len - 1;

	@try {
		for (i = 1; strs[i] != NULL; i++)
			append(&ret, &len, &pos, strs[i], self);







|
|







246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261

	len = strlen(*strs);
	if (SIZE_MAX - len < 1)
		@throw [OFOutOfRangeException newWithClass: self];
	len++;

	if ((ret = malloc(len)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: self
						    andSize: len];

	memcpy(ret, strs[0], len - 1);
	pos = len - 1;

	@try {
		for (i = 1; strs[i] != NULL; i++)
			append(&ret, &len, &pos, strs[i], self);