• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/tcl-105/tcl_ext/tdom/tdom/generic/

Lines Matching refs:block

135     domAllocBlock  * block,
145 if (hashedBlock == block) {
146 /* all is fine, block is already in hash table */
154 /* add block in hash table */
155 if (block->hashIndex1 == -1) {
156 block->hashIndex1 = i;
157 block->hashNext1 = bins.hashedBlocks[i];
159 if (block->hashIndex2 == -1) {
160 block->hashIndex2 = i;
161 block->hashNext2 = bins.hashedBlocks[i];
165 (unsigned int)block,
166 (unsigned int)mem, i, block->hashIndex1, block->hashIndex2);)
168 bins.hashedBlocks[i] = block;
181 domAllocBlock * block;
226 DBG(fprintf(stderr, "allocating new block ... \n");)
228 | allocate and initialize a new block
235 block = (domAllocBlock *)malloc( blockSize );
236 block->bin = bin;
237 block->end = (char*)block + blockSize;
238 block->slots = slots;
239 block->freeSlots = slots;
240 block->bitmaps = bitmaps;
241 block->freePos = 0;
242 block->freeBit = 0;
243 block->freeMask = 0x80000000;
244 block->hashIndex1 = -1;
245 block->hashNext1 = NULL;
246 block->hashIndex2 = -1;
247 block->hashNext2 = NULL;
249 usedBitmap = (unsigned int *) ((char*)block + sizeof(domAllocBlock));
256 block->prev = NULL; /* prepend this new block to free list */
257 block->next = bin->freeBlocks;
258 bin->freeBlocks = block;
261 | enter block in 'hash' table:
266 fillHashTable (block, mem);
268 fillHashTable (block, mem);
271 block = bin->freeBlocks;
275 | find free slot in (partial) free block
278 usedBitmap = (unsigned int *) ((char*)block + sizeof(domAllocBlock));
279 i = block->freePos; /* start at old pos to quickly find a free slot */
280 j = block->freeBit;
281 mask = block->freeMask;
290 mem = ((char*)usedBitmap) + (4*block->bitmaps) + ((i*32)+j) * size;
292 block->freeSlots--;
294 if (block->freeSlots == 0) {
297 if (block->prev == NULL) { /* remove block from free list */
298 bin->freeBlocks = block->next;
300 block->prev->next = block->next;
302 if (block->next) block->next->prev = block->prev;
304 block->next = bin->usedBlocks; /* add block to used list */
305 if (block->next) block->next->prev = block;
306 block->prev = NULL;
307 bin->usedBlocks = block;
310 hashedBlock = block->bin->freeBlocks;
312 if (hashedBlock == block) {
313 DBG(fprintf(stderr, "strange block still in free list \n");)
322 block->freePos = i;
325 block->freeBit = j;
326 block->freeMask = mask;
333 } while (j != block->freeBit);
336 if (i >= block->bitmaps) i = 0;
337 } while (i != block->freePos);
356 domAllocBlock * block;
375 | Find the block, which corresponds to the given memory location
380 block = NULL;
386 block = bins.blockCache[i];
392 | - Otherwise try to lookup corresponding block in hashtable
397 block = bins.hashedBlocks[i];
398 while (block != NULL) {
399 if ((mem > (void*)block) && (mem < (void*)(block->end))) break;
400 if (block->hashIndex1 == i) block = block->hashNext1;
401 else if (block->hashIndex2 == i) block = block->hashNext2;
402 else block = NULL;
406 if (block == NULL) {
415 usedBitmap = (unsigned int *) ((char*)block + sizeof(domAllocBlock));
416 slotNr = ( (char*)mem - (char*)usedBitmap - block->bitmaps*4 ) / block->bin->size;
418 if (slotNr >= block->slots) {
424 block->freeSlots++;
425 block->bin->freeSlots++;
428 if ((block->freeSlots < 1) || (block->freeSlots > block->slots)) {
429 fprintf(stderr, "assertion failed: freeSlots = %d \n", block->freeSlots);
435 if (block->freeSlots == 1) {
436 if (block->prev == NULL) { /* remove block from used list */
437 block->bin->usedBlocks = block->next;
439 block->prev->next = block->next;
441 if (block->next) block->next->prev = block->prev;
443 block->next = block->bin->freeBlocks; /* add block to free list */
444 if (block->next) block->next->prev = block;
445 block->prev = NULL;
446 block->bin->freeBlocks = block;
450 hashedBlock = block->bin->usedBlocks;
452 if (hashedBlock == block) {
453 fprintf(stderr, "strange block still in used list \n");
461 | free the whole block, when all slots are freed
463 if (block->freeSlots == block->slots) {
465 DBG(fprintf(stderr, "block completely freed %x\n",
466 (unsigned int)block);)
468 if (block->prev == NULL) { /* remove block from free list */
469 block->bin->freeBlocks = block->next;
471 block->prev->next = block->next;
473 if (block->next) block->next->prev = block->prev;
475 block->bin->nrSlots -= block->slots;
476 block->bin->freeSlots -= block->slots;
477 block->bin->nrBlocks--;
480 | remove block from (two) hash lists
482 i = block->hashIndex1;
488 if (hashedBlock == block) break;
495 bins.hashedBlocks[i] = block->hashNext1;
497 if (prevBlock->hashIndex1 == i) prevBlock->hashNext1 = block->hashNext1;
498 else if (prevBlock->hashIndex2 == i) prevBlock->hashNext2 = block->hashNext1;
501 i = block->hashIndex2;
507 if (hashedBlock == block) break;
514 bins.hashedBlocks[i] = block->hashNext2;
516 if (prevBlock->hashIndex1 == i) prevBlock->hashNext1 = block->hashNext2;
517 else if (prevBlock->hashIndex2 == i) prevBlock->hashNext2 = block->hashNext2;
522 | remove block from cache, if found
525 if (bins.blockCache[i] == block) {
532 for (i=0; i < block->bitmaps; i++) {
540 if (hashedBlock == block) {
541 fprintf(stderr, "strange block %d still in hash table \n", i);
548 hashedBlock = block->bin->freeBlocks;
550 if (hashedBlock == block) {
551 fprintf(stderr, "strange block still in free list \n");
555 hashedBlock = block->bin->usedBlocks;
557 if (hashedBlock == block) {
558 fprintf(stderr, "strange block still in used list \n");
563 free((char*)block);
570 /* remove oldest entry and add this block */
574 bins.blockCache[CACHE_SIZE-1] = block;