pike.git / src / block_allocator.c

version» Context lines:

pike.git/src/block_allocator.c:446:    p->next = p->prev = 0;    a->first = p;    IF_HASH(    ba_htable_insert(a, BA_LASTBLOCK(a, p), a->num_pages);   #ifdef BA_DEBUG    ba_check_allocator(a, "ba_alloc after insert", __FILE__, __LINE__);   #endif    );    p->blocks_used = 1;    p->first = BA_BLOCKN(a, p, 1); -  -  for (i = 1; i+1 < a->blocks; i++) { +  if (a->blueprint) { +  size_t clen = a->block_size, len; +  memcpy((char*)p->data, a->blueprint, clen); +  p->data->next = clen; +  len = (a->blocks-1) * clen; +  while (clen < len) { +  memcpy((char*)p->data + clen, +  (char*)p->data, clen); +  len -= clen; +  clen <<= 1; +  } +  memcpy((char*)p->data + clen, +  (char*)p->data, len); +  } else { +  ba_block_t i; +  for (i = 1; i < a->blocks; i++) { +  BA_BLOCKN(a, p, i)->next = a->block_size; +  }   #ifdef BA_DEBUG    PIKE_MEM_RW(BA_BLOCKN(a, p, i)->magic);    BA_BLOCKN(a, p, i)->magic = BA_MARK_FREE;   #endif -  BA_BLOCKN(a, p, i)->next = BA_BLOCKN(a, p, i+1); +     }    BA_LASTBLOCK(a, p)->next = NULL;    //memset(p->data, 0x00, BA_PAGESIZE(a));   #ifdef BA_DEBUG    PIKE_MEM_RW(BA_LASTBLOCK(a, p)->magic);    BA_LASTBLOCK(a, p)->magic = BA_MARK_FREE;    PIKE_MEM_RW(BA_BLOCKN(a, p, 0)->magic);    BA_BLOCKN(a, p, 0)->magic = BA_MARK_ALLOC;    ba_check_allocator(a, "ba_alloc after insert", __FILE__, __LINE__);   #endif