Changeset 2701
- Timestamp:
- 04/29/05 22:45:29 (4 years ago)
- Files:
-
- ZankaAdditions/trunk/ZANotificationCenter.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ZankaAdditions/trunk/ZANotificationCenter.m
r1749 r2701 61 61 62 62 ZANotificationCenterObserver **chunks; 63 ZANotificationCenterObserver *list; 64 unsigned int count; 65 unsigned int offset; 63 unsigned int chunkCount; 64 unsigned int chunkOffset; 65 66 ZANotificationCenterObserver *freeList; 66 67 67 68 pthread_mutex_t mutex; … … 126 127 storage = (ZANotificationCenterStorage *) malloc(sizeof(ZANotificationCenterStorage)); 127 128 memset(storage, 0, sizeof(ZANotificationCenterStorage)); 128 storage-> offset = ZANotificationCenterZoneSize;129 storage->chunkOffset = ZANotificationCenterZoneSize; 129 130 pthread_mutex_init(&storage->mutex, NULL); 130 131 ZANSNotificationCenterVars(self)->_pad[0] = (void *) storage; … … 162 163 storage = ZANSNotificationCenterVars(self)->_pad[0]; 163 164 164 for(i = 0; i < storage->c ount; i++)165 for(i = 0; i < storage->chunkCount; i++) 165 166 free(storage->chunks[i]); 166 167 … … 242 243 size_t size; 243 244 244 if(!storage-> list) {245 if(storage-> offset == ZANotificationCenterZoneSize) {246 storage->c ount++;247 248 size = storage->c ount * sizeof(ZANotificationCenterObserver *);245 if(!storage->freeList) { 246 if(storage->chunkOffset == ZANotificationCenterZoneSize) { 247 storage->chunkCount++; 248 249 size = storage->chunkCount * sizeof(ZANotificationCenterObserver *); 249 250 storage->chunks = (ZANotificationCenterObserver **) 250 251 realloc(storage->chunks, size); 251 252 252 253 size = ZANotificationCenterZoneSize * sizeof(ZANotificationCenterObserver); 253 storage->chunks[storage->c ount - 1] = (ZANotificationCenterObserver *)254 storage->chunks[storage->chunkCount - 1] = (ZANotificationCenterObserver *) 254 255 malloc(size); 255 256 256 storage-> offset = 0;257 storage->chunkOffset = 0; 257 258 } 258 259 259 observerBlock = storage->chunks[storage->count - 1]; 260 storage->list = &observerBlock[storage->offset]; 261 storage->offset++; 262 storage->list->link = NULL; 260 observerBlock = storage->chunks[storage->chunkCount - 1]; 261 storage->freeList = &observerBlock[storage->chunkOffset++]; 262 storage->freeList->link = NULL; 263 263 } 264 264 265 observer = storage-> list;266 storage-> list = observer->link;265 observer = storage->freeList; 266 storage->freeList = observer->link; 267 267 268 268 return observer; … … 370 370 storage->observers[index] = observer->next; 371 371 372 observer->link = storage-> list;373 storage-> list = observer;372 observer->link = storage->freeList; 373 storage->freeList = observer; 374 374 } 375 375 } … … 394 394 storage->observers[i] = observer->next; 395 395 396 observer->link = storage-> list;397 storage-> list = observer;396 observer->link = storage->freeList; 397 storage->freeList = observer; 398 398 } 399 399 }
