Differences From Artifact [1ada4c447c]:
- File src/OFStream.m — part of check-in [94ea6848a8] at 2009-05-24 18:04:09 on branch trunk — Always use #include "config.h" instead of #import "config.h". (user: js, size: 3820) [annotate] [blame] [check-ins using]
To Artifact [3f64dd68d8]:
- File
src/OFStream.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: 3921) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
60 61 62 63 64 65 66 | OFString *ret; /* Look if there's a line or \0 in our cache */ if (cache != NULL) { for (i = 0; i < cache_len; i++) { if (OF_UNLIKELY(cache[i] == '\n' || cache[i] == '\0')) { | | | > | | | | | | | > | | > | | | | | | | | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 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 168 169 170 | OFString *ret; /* Look if there's a line or \0 in our cache */ if (cache != NULL) { for (i = 0; i < cache_len; i++) { if (OF_UNLIKELY(cache[i] == '\n' || cache[i] == '\0')) { ret_c = [self allocMemoryWithSize: i + 1]; memcpy(ret_c, cache, i); ret_c[i] = '\0'; @try { tmp = [self allocMemoryWithSize: cache_len - i - 1]; } @catch (OFException *e) { [self freeMemory: ret_c]; @throw e; } memcpy(tmp, cache + i + 1, cache_len - i - 1); [self freeMemory: cache]; cache = tmp; cache_len = cache_len - i - 1; @try { ret = [OFString stringWithCString: ret_c]; } @finally { [self freeMemory: ret_c]; } return ret; } } } /* Read until we get a newline or \0 */ tmp = [self allocMemoryWithSize: pagesize]; for (;;) { @try { len = [self readNBytes: pagesize - 1 intoBuffer: tmp]; } @catch (OFException *e) { [self freeMemory: tmp]; @throw e; } /* Look if there's a newline or \0 */ for (i = 0; i < len; i++) { if (OF_UNLIKELY(tmp[i] == '\n' || tmp[i] == '\0')) { @try { ret_c = [self allocMemoryWithSize: cache_len + i + 1]; } @catch (OFException *e) { [self freeMemory: tmp]; @throw e; } if (cache != NULL) memcpy(ret_c, cache, cache_len); memcpy(ret_c + cache_len, tmp, i); ret_c[i] = '\0'; if (i < len) { @try { tmp2 = [self allocMemoryWithSize: len - i - 1]; } @catch (OFException *e) { [self freeMemory: ret_c]; [self freeMemory: tmp]; @throw e; } memcpy(tmp2, tmp + i + 1, len - i - 1); if (cache != NULL) [self freeMemory: cache]; cache = tmp2; cache_len = len - i - 1; } else { if (cache != NULL) [self freeMemory: cache]; cache = NULL; cache_len = 0; } [self freeMemory: tmp]; @try { ret = [OFString stringWithCString: ret_c]; } @finally { [self freeMemory: ret_c]; } return ret; } } /* There was no newline or \0 */ @try { cache = [self resizeMemory: cache toSize: cache_len + len]; } @catch (OFException *e) { [self freeMemory: tmp]; @throw e; } memcpy(cache + cache_len, tmp, len); cache_len += len; } } |
︙ | ︙ | |||
185 186 187 188 189 190 191 | return cache_len; } - clearCache { if (cache != NULL) | | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | return cache_len; } - clearCache { if (cache != NULL) [self freeMemory: cache]; cache = NULL; cache_len = 0; return self; } - close { @throw [OFNotImplementedException newWithClass: isa andSelector: _cmd]; } @end |