extern "C" void* calloc(size_t nmemb, size_t size)
{
    REF;
    void* out = __libc_calloc(nmemb, size);
    DEREF;
    if (out && D) {
        D->now_usable.fetchAndAddOrdered(malloc_usable_size(out));
        D->now_overhead.fetchAndAddOrdered(CHUNK_OVERHEAD);
        D->updatePeak();
    }
    return out;
}
예제 #2
0
/* 0.15 requires we track calloc too */
void* calloc(size_t nmemb, size_t sz) {
    if (!next_calloc) {
        extern void* __libc_calloc(size_t nmemb, size_t sz);
        return __libc_calloc(nmemb, sz); /* avoid infinite regress */
    }

    if (test_mode == 2)
        check();

    void* ptr = next_calloc(nmemb, sz);

    if (test_mode >= 0)
        track(1, sz, ptr);
    return ptr;
}
예제 #3
0
void* calloc(size_t n, size_t size)
{
  void* ret;
  if( !chpl_mem_inited() ) {
    ret = __libc_calloc(n, size);
    if( DEBUG_REPLACE_MALLOC ) 
      printf("in early calloc %p = system calloc(%#x)\n", ret, (int) (n*size));
    track_system_allocated(ret, n*size, __libc_malloc);
    return ret;
  }
  if( DEBUG_REPLACE_MALLOC ) 
    printf("in calloc\n");

  ret = chpl_calloc(n, size);

  if( DEBUG_REPLACE_MALLOC ) 
    printf("%p = chpl_calloc(%#x)\n", ret, (int) (n*size));

  return ret;
}
예제 #4
0
파일: unittest.c 프로젝트: ezorita/mapper
void *
fail_prone_calloc(size_t nitems, size_t size)
{
   return drand48() < ALLOC_ERR_PROB ? NULL : __libc_calloc(nitems, size);
}
예제 #5
0
파일: unittest.c 프로젝트: ezorita/mapper
void *
fail_countdown_calloc(size_t nitems, size_t size)
{
   if (ALLOC_FAIL_COUNTER >= 0) ALLOC_FAIL_COUNTER--;
   return ALLOC_FAIL_COUNTER < 0 ? NULL : __libc_calloc(nitems, size);
}
예제 #6
0
파일: wrapper.c 프로젝트: AllardJ/Tomato
void *calloc(size_t nmemb, size_t size)
{
        void *__libc_calloc(size_t nmemb, size_t size);
        return __libc_calloc(nmemb, size);
}