コード例 #1
0
ファイル: heap.c プロジェクト: HuangZhenQiu/NanoKong
void heap_realloc(heap_id_t id, u16_t size) {
  heap_t *h, *h_new;

  DEBUGF_HEAP("heap_realloc(id=0x%04x, size=%d)\n", id, size);

  // check free mem and call garbage collection if required
  h = (heap_t*)&heap[heap_base];
  // (no HEAP_LEN_MASK required for free chunk)
  if(h->len < size + sizeof(heap_t))
    heap_garbage_collect();

  // get info on old chunk
  h = heap_search(id);

  // allocate space for bigger one
  if(!heap_alloc_internal(id, h->len & HEAP_FIELDREF_MASK ? TRUE : FALSE, size))
    error(ERROR_HEAP_OUT_OF_MEMORY);

  h_new = heap_search(id);

  utils_memcpy(h_new+1, h+1, h->len & HEAP_LEN_MASK);

  // this chunk is not immediately available for new allocation
  // but it will be removed by the garbage collection next time 
  h->id = HEAP_ID_FREE;
}
コード例 #2
0
ファイル: heap.c プロジェクト: HuangZhenQiu/NanoKong
void *heap_get_addr(heap_id_t id) {
  heap_t *h = heap_search(id);
  if(!h) {
    DEBUGF_HEAP("Chunk does not exist for heap_id: %x\n", id);
    error(ERROR_HEAP_CHUNK_DOES_NOT_EXIST); 
  }
  return h+1;
}
コード例 #3
0
ファイル: heap.c プロジェクト: HuangZhenQiu/NanoKong
u16_t heap_get_len(heap_id_t id) {
  heap_t *h = heap_search(id);
  if(!h) {
    DEBUGF_HEAP("Chunk does not exist for heap_id: %x\n", id);
    error(ERROR_HEAP_CHUNK_DOES_NOT_EXIST); 
  }
  return h->len & HEAP_LEN_MASK;
}
コード例 #4
0
ファイル: heap.c プロジェクト: HuangZhenQiu/NanoKong
heap_id_t heap_new_id(void) {
  heap_id_t id;

  for(id=1;id;id++) 
    if(heap_search(id) == NULL) 
      return id;

  return 0;
}
コード例 #5
0
ファイル: pqbench.c プロジェクト: gedare/pqstbench
uint64_t pq_search( rtems_task_argument tid, int key ) {
  return heap_search(tid, key);
}