Exemplo n.º 1
0
Arquivo: suba.c Projeto: nafraf/CHDK
void *
suba_realloc(struct allocator *suba, void *ptr, size_t size)
{
    struct cell *c;
    void *p;

    if (ptr == NULL) {
        if ((p = suba_alloc(suba, size, 0)) == NULL) {
            AMSG("");
        }
        return p;
    }
    if (size == 0) {
        suba_free(suba, ptr);
        return NULL;
    }
    c = P2C(ptr);
    if (c->size < size || (c->size - ALIGN(size)) > suba->mincell) {
        p = suba_alloc(suba, size, 0);
    } else {
        return ptr;
    }
    if (p) {
        memcpy(p, ptr, size);
        suba_free(suba, ptr);
    }

    return p;
}
Exemplo n.º 2
0
static int chdk_free(chdk_heap *h, void *p)
{
    if (h && h->heap && (p >= h->start) && (p < h->end))
    {
        suba_free(h->heap,p);
        return 1;
    }
    return 0;
}
Exemplo n.º 3
0
int
allocator_free(void *al0, void *obj)
{
	struct allocator *al = al0;

	if (!al) {
		al = global_allocator ? global_allocator : stdlib_allocator;
	}

	if (al->tail) { /* fn ptr in shared mem may be invalid */
		if (suba_free(al, obj) == -1) {
			AMSG("");
			return -1;
		}
	} else if (al->free(al, obj) == -1) {
		AMSG("");
		return -1;
	}

	return 0;
}
Exemplo n.º 4
0
void
kogmo_rtdb_obj_mem_free (kogmo_rtdb_handle_t *db_h, kogmo_rtdb_objsize_t idx,
                         kogmo_rtdb_objsize_t size )
{
#if defined(RTMALLOC_tlsf)
    void *base = db_h->localdata_p->heap;
#endif
    void *ptr = db_h->localdata_p->heap + idx;
    DBGL(DBGL_DB,"mem_free: %i bytes at %p", size, ptr);
    kogmo_rtdb_heap_lock(db_h);
#if defined(RTMALLOC_tlsf)
    free_ex (ptr, base);
    db_h->localdata_p->heap_free += size;
    db_h->localdata_p->heap_used -= size;
#elif defined(RTMALLOC_suba)
    suba_free (db_h-> heapinfo, ptr);
    db_h->localdata_p->heap_free += size;
    db_h->localdata_p->heap_used -= size;
#else
// do nothing
#endif
    kogmo_rtdb_heap_unlock(db_h);
}
Exemplo n.º 5
0
void free(void *p) {
	if(exmem_heap && (p >= exmem_heap))
		suba_free(exmem_heap,p);
	else
		_free(p);
}