Overview
| Comment: | Fix reference counting for blocks. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | 0.5 |
| Files: | files | file ages | folders |
| SHA3-256: |
66be98f1d1b7df4f3b26b45ee0d5958d |
| User & Date: | js on 2011-07-14 23:06:11 |
| Other Links: | branch diff | manifest | tags |
Context
|
2011-07-14
| ||
| 23:15 | Fix missing autoreleases in OFBlockTests.m. (check-in: 47611ea871 user: js tags: 0.5) | |
| 23:06 | Fix reference counting for blocks. (check-in: 66be98f1d1 user: js tags: 0.5) | |
| 23:04 | Always do nothing if OF_BLOCK_BYREF_CALLER is set. (check-in: 0c5ed4d438 user: js tags: 0.5) | |
Changes
Modified src/OFBlock.m from [c7116e51f3] to [b9b5eda4af].
| ︙ | ︙ | |||
251 252 253 254 255 256 257 | case OF_BLOCK_FIELD_IS_OBJECT: *(id*)dst_ = [(id)src_ retain]; break; case OF_BLOCK_FIELD_IS_BYREF:; of_block_byref_t *src = (of_block_byref_t*)src_; of_block_byref_t **dst = (of_block_byref_t**)dst_; | | > > > | 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 278 279 |
case OF_BLOCK_FIELD_IS_OBJECT:
*(id*)dst_ = [(id)src_ retain];
break;
case OF_BLOCK_FIELD_IS_BYREF:;
of_block_byref_t *src = (of_block_byref_t*)src_;
of_block_byref_t **dst = (of_block_byref_t**)dst_;
if ((src->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
if ((*dst = malloc(src->size)) == NULL) {
alloc_failed_exception.isa =
[OFAllocFailedException class];
@throw (OFAllocFailedException*)
&alloc_failed_exception;
}
if (src->forwarding == src)
src->forwarding = *dst;
memcpy(*dst, src, src->size);
/* src->forwarding points to us -> that's a reference */
(*dst)->flags++;
if (src->size >= sizeof(of_block_byref_t))
src->byref_keep(*dst, src);
} else
*dst = src;
(*dst)->flags++;
|
| ︙ | ︙ | |||
296 297 298 299 300 301 302 | break; case OF_BLOCK_FIELD_IS_OBJECT: [(id)obj_ release]; break; case OF_BLOCK_FIELD_IS_BYREF:; of_block_byref_t *obj = (of_block_byref_t*)obj_; | | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
break;
case OF_BLOCK_FIELD_IS_OBJECT:
[(id)obj_ release];
break;
case OF_BLOCK_FIELD_IS_BYREF:;
of_block_byref_t *obj = (of_block_byref_t*)obj_;
if ((--obj->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
if (obj->size >= sizeof(of_block_byref_t))
obj->byref_dispose(obj);
free(obj);
}
break;
}
|
| ︙ | ︙ |