ObjFW  Check-in [758559fd9f]

Overview
Comment:Make reference counting of blocks atomic.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 758559fd9fbe3c8969db7bdf92bfefafd2d74f148f989698b90e0681aaeee9f7
User & Date: js on 2010-10-31 22:01:52
Other Links: manifest | tags
Context
2010-10-31
22:18
Check if 64 bit version of OSAtomic* functions is available. check-in: 9626d917a6 user: js tags: trunk
22:01
Make reference counting of blocks atomic. check-in: 758559fd9f user: js tags: trunk
21:59
More atomic operations. check-in: dd061ee65e user: js tags: trunk
Changes

Modified src/OFBlock.m from [8d52188a1e] to [239ba34c9f].

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
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







-
+












-
+







		if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
			block->descriptor->copy_helper(copy, block);

		return copy;
	}

	if (block->isa == (Class)&_NSConcreteMallocBlock)
		block->reserved++;
		of_atomic_inc_int(&block->reserved);

	return block;
}

void
_Block_release(const void *block_)
{
	of_block_literal_t *block = (of_block_literal_t*)block_;

	if (block->isa != (Class)&_NSConcreteMallocBlock)
		return;

	if (--block->reserved == 0) {
	if (of_atomic_dec_int(&block->reserved) == 0) {
		if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
			block->descriptor->dispose_helper(block);

		free(block);
	}
}