Overview
| Comment: | Fix reference counting for blocks. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
5b3aebb65ab10b521b4b1cfe86aae4e4 |
| User & Date: | js on 2011-07-14 23:06:11 |
| Other Links: | manifest | tags |
Context
|
2011-07-14
| ||
| 23:15 | Fix missing autoreleases in OFBlockTests.m. (check-in: 33c7abb54b user: js tags: trunk) | |
| 23:06 | Fix reference counting for blocks. (check-in: 5b3aebb65a user: js tags: trunk) | |
| 23:04 | Always do nothing if OF_BLOCK_BYREF_CALLER is set. (check-in: eb207e5ecd user: js tags: trunk) | |
Changes
Modified src/OFBlock.m from [feff30d170] to [ff454a2522].
| ︙ | ︙ | |||
280 281 282 283 284 285 286 | 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_; | | > > > | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
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++;
|
| ︙ | ︙ | |||
325 326 327 328 329 330 331 | 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_; | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
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;
}
|
| ︙ | ︙ |