コード例 #1
0
ファイル: zmalloc.c プロジェクト: lubing521/QQNetwork
void *zrealloc(void *ptr, size_t size) {
#ifndef HAVE_MALLOC_SIZE
    void *realptr;
#endif
    size_t oldsize;
    void *newptr;

    if (ptr == NULL) return zmalloc(size);
#ifdef HAVE_MALLOC_SIZE
    oldsize = zmalloc_size(ptr);
    newptr = realloc(ptr,size);
    if (!newptr) zmalloc_oom(size);

    update_zmalloc_stat_free(oldsize);
    update_zmalloc_stat_alloc(zmalloc_size(newptr),size);
    return newptr;
#else
    realptr = (char*)ptr-PREFIX_SIZE;
    oldsize = *((size_t*)realptr);
    newptr = realloc(realptr,size+PREFIX_SIZE);
    if (!newptr) zmalloc_oom(size);

    *((size_t*)newptr) = size;
    update_zmalloc_stat_free(oldsize);
    update_zmalloc_stat_alloc(size,size);
    return (char*)newptr+PREFIX_SIZE;
#endif
}
コード例 #2
0
ファイル: zmalloc.c プロジェクト: jango2015/appnet_php7
void zfree(void *ptr) {
#ifndef HAVE_MALLOC_SIZE
    void *realptr;
    size_t oldsize;
#endif
    if (ptr == NULL) return;
#ifdef HAVE_MALLOC_SIZE
    update_zmalloc_stat_free(zmalloc_size(ptr));
    free(ptr);
#else
    realptr = (char*)ptr-PREFIX_SIZE;
    oldsize = *((size_t*)realptr);
    update_zmalloc_stat_free(oldsize+PREFIX_SIZE);
    free(realptr);
#endif
}
コード例 #3
0
ファイル: ez_malloc.c プロジェクト: ezzuodp/c_util
void zfree(void *ptr)
{
	if (ptr == NULL)
		return;
	update_zmalloc_stat_free(__malloc_size(ptr));
	__free(ptr);
}
コード例 #4
0
ファイル: zmalloc.c プロジェクト: sharpllr/spongedb
void zfree(void *ptr)
{
    void *realptr;
    size_t oldsize;
    
    if (ptr == NULL)
        return;
    
    realptr = (char*) ptr - PREFIX_SIZE;
    oldsize = *((size_t*) realptr);
    update_zmalloc_stat_free(oldsize+PREFIX_SIZE);
    free(realptr);
}
コード例 #5
0
ファイル: zmalloc.c プロジェクト: davinash/redis-win
void *zrealloc(void *ptr, size_t size) {
#ifndef HAVE_MALLOC_SIZE
    void *realptr;
#endif
    size_t oldsize;
    void *newptr;

#ifdef WIN32
    if ( mutex_initialized == 0 ) {
      pthread_mutex_init(&used_memory_mutex, NULL );
      mutex_initialized = 1 ;
    }
#endif


    if (ptr == NULL) return zmalloc(size);
#ifdef HAVE_MALLOC_SIZE
    oldsize = zmalloc_size(ptr);
    newptr = realloc(ptr,size);
    if (!newptr) zmalloc_oom_handler(size);

    update_zmalloc_stat_free(oldsize);
    update_zmalloc_stat_alloc(zmalloc_size(newptr),size);
    return newptr;
#else
    realptr = (char*)ptr-PREFIX_SIZE;
    oldsize = *((size_t*)realptr);
    newptr = realloc(realptr,size+PREFIX_SIZE);
    if (!newptr) zmalloc_oom_handler(size);

    *((size_t*)newptr) = size;
    update_zmalloc_stat_free(oldsize);
    update_zmalloc_stat_alloc(size,size);
    return (char*)newptr+PREFIX_SIZE;
#endif
}
コード例 #6
0
ファイル: ez_malloc.c プロジェクト: ezzuodp/c_util
void *zrealloc(void *ptr, size_t size)
{
	size_t oldsize;
	void *newptr;

	if (ptr == NULL)
		return zmalloc(size);
	oldsize = __malloc_size(ptr);
	newptr = __realloc(ptr, size);
	if (!newptr)
		zmalloc_oom_handler(size);

	update_zmalloc_stat_free(oldsize);
	update_zmalloc_stat_alloc(__malloc_size(newptr));
	return newptr;
}
コード例 #7
0
ファイル: zmalloc.c プロジェクト: hylaz/redis
void zfree_no_tcache(void *ptr) {
    if (ptr == NULL) return;
    update_zmalloc_stat_free(zmalloc_size(ptr));
    dallocx(ptr, MALLOCX_TCACHE_NONE);
}