The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.
SparseMatrix B = NULL;
if (!A) return NULL;
if (nz > 0){
- irn = MALLOC(sizeof(int)*((size_t)nz)*2);
- jcn = MALLOC(sizeof(int)*((size_t)nz)*2);
+ irn = gv_calloc((size_t)nz * 2, sizeof(int));
+ jcn = gv_calloc((size_t)nz * 2, sizeof(int));
}
if (A->a){
assert(A->size != 0 && nz > 0);
- val = MALLOC(A->size*2*((size_t)nz));
+ val = gv_calloc(2 * (size_t)nz, A->size);
memcpy(val, A->a, A->size*((size_t)nz));
memcpy(((char*) val) + ((size_t)nz)*A->size, A->a, A->size*((size_t)nz));
}