Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-01-26 00:18:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-26 00:18:12 +0400
commitc7e8af13d4aefe8237e925bf817c56e802aaf7b0 (patch)
tree2f34713219c9641ac5aa9f78af756a49c18dc0bd /source/blender/blenkernel/intern
parent4fae6cd38d55997e77fdbe31e204511a2a9de154 (diff)
remove cellalloc, from my tests jemalloc beats cellalloc, so we better just use a better malloc replacement.
See Details: http://wiki.blender.org/index.php/User:Ideasman42/BMeshBranchReview#Update_43694
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/customdata.c31
-rw-r--r--source/blender/blenkernel/intern/deform.c21
-rw-r--r--source/blender/blenkernel/intern/mesh.c9
-rw-r--r--source/blender/blenkernel/intern/multires.c21
-rw-r--r--source/blender/blenkernel/intern/particle.c1
-rw-r--r--source/blender/blenkernel/intern/particle_system.c5
6 files changed, 40 insertions, 48 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 1ad439ef29b..4dbb143a73e 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -49,7 +49,6 @@
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_mempool.h"
-#include "BLI_cellalloc.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
@@ -139,7 +138,7 @@ static void layerCopy_mdeformvert(const void *source, void *dest,
MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size);
if(dvert->totweight) {
- MDeformWeight *dw = BLI_cellalloc_calloc(dvert->totweight * sizeof(*dw),
+ MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw),
"layerCopy_mdeformvert dw");
memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw));
@@ -158,7 +157,7 @@ static void layerFree_mdeformvert(void *data, int count, int size)
MDeformVert *dvert = (MDeformVert *)((char *)data + i * size);
if(dvert->dw) {
- BLI_cellalloc_free(dvert->dw);
+ MEM_freeN(dvert->dw);
dvert->dw = NULL;
dvert->totweight = 0;
}
@@ -167,7 +166,7 @@ static void layerFree_mdeformvert(void *data, int count, int size)
static void linklist_free_simple(void *link)
{
- BLI_cellalloc_free(link);
+ MEM_freeN(link);
}
static void layerInterp_mdeformvert(void **sources, float *weights,
@@ -200,7 +199,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights,
/* if this def_nr is not in the list, add it */
if(!node) {
- MDeformWeight *tmp_dw = BLI_cellalloc_calloc(sizeof(*tmp_dw),
+ MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw),
"layerInterp_mdeformvert tmp_dw");
tmp_dw->def_nr = dw->def_nr;
tmp_dw->weight = dw->weight * interp_weight;
@@ -211,10 +210,10 @@ static void layerInterp_mdeformvert(void **sources, float *weights,
}
/* now we know how many unique deform weights there are, so realloc */
- if(dvert->dw) BLI_cellalloc_free(dvert->dw);
+ if(dvert->dw) MEM_freeN(dvert->dw);
if(totweight) {
- dvert->dw = BLI_cellalloc_calloc(sizeof(*dvert->dw) * totweight,
+ dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight,
"layerInterp_mdeformvert dvert->dw");
dvert->totweight = totweight;
@@ -430,18 +429,18 @@ static void layerSwap_mdisps(void *data, const int *ci)
/* happens when face changed vertex count in edit mode
if it happened, just forgot displacement */
- BLI_cellalloc_free(s->disps);
+ MEM_freeN(s->disps);
s->totdisp= (s->totdisp/corners)*nverts;
- s->disps= BLI_cellalloc_calloc(s->totdisp*sizeof(float)*3, "mdisp swap");
+ s->disps= MEM_callocN(s->totdisp*sizeof(float)*3, "mdisp swap");
return;
}
- d= BLI_cellalloc_calloc(sizeof(float) * 3 * s->totdisp, "mdisps swap");
+ d= MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
for(S = 0; S < corners; S++)
memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float));
- BLI_cellalloc_free(s->disps);
+ MEM_freeN(s->disps);
s->disps= d;
}
}
@@ -458,7 +457,7 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
}
if (!d->disps && d->totdisp)
- d->disps = BLI_cellalloc_calloc(sizeof(float)*3*d->totdisp, "blank mdisps in layerInterp_mdisps");
+ d->disps = MEM_callocN(sizeof(float)*3*d->totdisp, "blank mdisps in layerInterp_mdisps");
}
#else // BMESH_TODO
@@ -585,7 +584,7 @@ static void layerCopy_mdisps(const void *source, void *dest, int count)
for(i = 0; i < count; ++i) {
if(s[i].disps) {
- d[i].disps = BLI_cellalloc_dupalloc(s[i].disps);
+ d[i].disps = MEM_dupallocN(s[i].disps);
d[i].totdisp = s[i].totdisp;
}
else {
@@ -609,7 +608,7 @@ static void layerValidate_mdisps(void *data, int sub_elements)
if(corners != sub_elements) {
MEM_freeN(disps->disps);
disps->totdisp = disps->totdisp / corners * sub_elements;
- disps->disps = BLI_cellalloc_calloc(3*disps->totdisp*sizeof(float), "layerValidate_mdisps");
+ disps->disps = MEM_callocN(3*disps->totdisp*sizeof(float), "layerValidate_mdisps");
}
}
#endif
@@ -622,7 +621,7 @@ static void layerFree_mdisps(void *data, int count, int UNUSED(size))
for(i = 0; i < count; ++i) {
if(d[i].disps)
- BLI_cellalloc_free(d[i].disps);
+ MEM_freeN(d[i].disps);
d[i].disps = NULL;
d[i].totdisp = 0;
}
@@ -635,7 +634,7 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
for(i = 0; i < count; ++i) {
if(!d[i].disps)
- d[i].disps = BLI_cellalloc_calloc(sizeof(float)*3*d[i].totdisp, "mdisps read");
+ d[i].disps = MEM_callocN(sizeof(float)*3*d[i].totdisp, "mdisps read");
if(!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp);
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 91345c26154..a95cd8d00d8 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -45,9 +45,6 @@
#include "BLI_utildefines.h"
-#include "BLI_cellalloc.h"
-
-
void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
{
bDeformGroup *defgroup, *defgroupn;
@@ -86,10 +83,10 @@ void defvert_copy(MDeformVert *dvert_dst, const MDeformVert *dvert_src)
}
else {
if (dvert_dst->dw)
- BLI_cellalloc_free(dvert_dst->dw);
+ MEM_freeN(dvert_dst->dw);
if (dvert_src->totweight)
- dvert_dst->dw= BLI_cellalloc_dupalloc(dvert_src->dw);
+ dvert_dst->dw= MEM_dupallocN(dvert_src->dw);
else
dvert_dst->dw= NULL;
@@ -587,10 +584,10 @@ MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
if (dw_new)
return dw_new;
- dw_new= BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dvert->totweight+1), "deformWeight");
+ dw_new= MEM_callocN(sizeof(MDeformWeight)*(dvert->totweight+1), "deformWeight");
if (dvert->dw) {
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
- BLI_cellalloc_free(dvert->dw);
+ MEM_freeN(dvert->dw);
}
dvert->dw= dw_new;
dw_new += dvert->totweight;
@@ -615,10 +612,10 @@ void defvert_add_index_notest(MDeformVert *dvert, int defgroup, const float weig
if (!dvert || defgroup < 0)
return;
- dw_new = BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dvert->totweight+1), "defvert_add_to group, new deformWeight");
+ dw_new = MEM_callocN(sizeof(MDeformWeight)*(dvert->totweight+1), "defvert_add_to group, new deformWeight");
if(dvert->dw) {
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
- BLI_cellalloc_free(dvert->dw);
+ MEM_freeN(dvert->dw);
}
dvert->dw = dw_new;
dw_new += dvert->totweight;
@@ -646,7 +643,7 @@ void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
* this deform weight, and reshuffle the others.
*/
if (dvert->totweight) {
- dw_new = BLI_cellalloc_malloc(sizeof(MDeformWeight)*(dvert->totweight), __func__);
+ dw_new = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), __func__);
if (dvert->dw) {
#if 1 /* since we dont care about order, swap this with the last, save a memcpy */
if (i != dvert->totweight) {
@@ -657,13 +654,13 @@ void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i);
memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i));
#endif
- BLI_cellalloc_free(dvert->dw);
+ MEM_freeN(dvert->dw);
}
dvert->dw = dw_new;
}
else {
/* If there are no other deform weights left then just remove this one. */
- BLI_cellalloc_free(dvert->dw);
+ MEM_freeN(dvert->dw);
dvert->dw = NULL;
}
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 44a204028f6..db31297a568 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -73,7 +73,6 @@
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_math.h"
-#include "BLI_cellalloc.h"
#include "BLI_array.h"
#include "BLI_edgehash.h"
@@ -437,7 +436,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
for (i=0; i<copycount; i++){
if (src[i].dw){
- dst[i].dw = BLI_cellalloc_calloc (sizeof(MDeformWeight)*src[i].totweight, "copy_deformWeight");
+ dst[i].dw = MEM_callocN (sizeof(MDeformWeight)*src[i].totweight, "copy_deformWeight");
memcpy (dst[i].dw, src[i].dw, sizeof (MDeformWeight)*src[i].totweight);
}
}
@@ -456,7 +455,7 @@ void free_dverts(MDeformVert *dvert, int totvert)
/* Free any special data from the verts */
for (i=0; i<totvert; i++){
- if (dvert[i].dw) BLI_cellalloc_free (dvert[i].dw);
+ if (dvert[i].dw) MEM_freeN (dvert[i].dw);
}
MEM_freeN (dvert);
}
@@ -1897,9 +1896,9 @@ static void bmesh_corners_to_loops(Mesh *me, int findex, int loopstart, int numT
ld->totdisp = side*side;
if (ld->disps)
- BLI_cellalloc_free(ld->disps);
+ MEM_freeN(ld->disps);
- ld->disps = BLI_cellalloc_calloc(sizeof(float)*3*side*side, "converted loop mdisps");
+ ld->disps = MEM_callocN(sizeof(float)*3*side*side, "converted loop mdisps");
if (fd->disps) {
memcpy(ld->disps, disps, sizeof(float)*3*side*side);
}
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index ba32e1ddac0..cba4780e282 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -45,7 +45,6 @@
#include "BLI_pbvh.h"
#include "BLI_editVert.h"
#include "BLI_utildefines.h"
-#include "BLI_cellalloc.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_mesh.h"
@@ -327,10 +326,10 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
/* reallocate displacements to be filled in */
for(i = 0; i < totloop; ++i) {
int totdisp = multires_grid_tot[lvl];
- float (*disps)[3] = BLI_cellalloc_calloc(sizeof(float) * 3 * totdisp, "multires disps");
+ float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps");
if(mdisps[i].disps)
- BLI_cellalloc_free(mdisps[i].disps);
+ MEM_freeN(mdisps[i].disps);
mdisps[i].disps = disps;
mdisps[i].totdisp = totdisp;
@@ -409,7 +408,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
float (*disps)[3], (*ndisps)[3], (*hdisps)[3];
int totdisp = multires_grid_tot[lvl];
- disps = BLI_cellalloc_calloc(sizeof(float) * 3 * totdisp, "multires disps");
+ disps = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps");
ndisps = disps;
hdisps = mdisp->disps;
@@ -419,7 +418,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
ndisps += nsize*nsize;
hdisps += hsize*hsize;
- BLI_cellalloc_free(mdisp->disps);
+ MEM_freeN(mdisp->disps);
mdisp->disps = disps;
mdisp->totdisp = totdisp;
}
@@ -977,7 +976,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
/* when adding new faces in edit mode, need to allocate disps */
if(!mdisp->disps) {
mdisp->totdisp = gridSize*gridSize;
- mdisp->disps = BLI_cellalloc_calloc(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space");
+ mdisp->disps = MEM_callocN(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space");
}
dispgrid = mdisp->disps;
@@ -1179,7 +1178,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
int x, y, S;
float (*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */
- disps = BLI_cellalloc_calloc(sizeof(float) * 3 * newtotdisp, "multires disps");
+ disps = MEM_callocN(sizeof(float) * 3 * newtotdisp, "multires disps");
out = disps;
for(S = 0; S < nvert; S++) {
@@ -1196,7 +1195,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
}
}
- BLI_cellalloc_free(mdisp->disps);
+ MEM_freeN(mdisp->disps);
mdisp->totdisp= newtotdisp;
mdisp->disps= disps;
@@ -1225,7 +1224,7 @@ void multires_load_old_250(Mesh *me)
int totdisp = mdisps[i].totdisp / nvert;
for (j=0; j < mf->v4 ? 4 : 3; j++, k++) {
- mdisps2[k].disps = BLI_cellalloc_calloc(sizeof(float)*3*totdisp, "multires disp in conversion");
+ mdisps2[k].disps = MEM_callocN(sizeof(float)*3*totdisp, "multires disp in conversion");
mdisps2[k].totdisp = totdisp;
memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp*j, totdisp);
}
@@ -2356,13 +2355,13 @@ void mdisp_join_tris(MDisps *dst, MDisps *tri1, MDisps *tri2)
MDisps *src;
if(dst->disps)
- BLI_cellalloc_free(dst->disps);
+ MEM_freeN(dst->disps);
side = sqrt(tri1->totdisp / 3);
st = (side<<1)-1;
dst->totdisp = 4 * side * side;
- out = dst->disps = BLI_cellalloc_calloc(3*dst->totdisp*sizeof(float), "join disps");
+ out = dst->disps = MEM_callocN(3*dst->totdisp*sizeof(float), "join disps");
for(S = 0; S < 4; S++)
for(y = 0; y < side; ++y)
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index a645cb79953..132b721006e 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -55,7 +55,6 @@
#include "BLI_threads.h"
#include "BLI_linklist.h"
#include "BLI_bpath.h"
-#include "BLI_cellalloc.h"
#include "BLI_math.h"
#include "BKE_anim.h"
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 69ddcd21cb9..7587bfc4be8 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -71,7 +71,6 @@
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
#include "BLI_edgehash.h"
-#include "BLI_cellalloc.h"
#include "BKE_main.h"
#include "BKE_animsys.h"
@@ -3537,7 +3536,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
if(dvert) {
if(!dvert->totweight) {
- dvert->dw = BLI_cellalloc_calloc(sizeof(MDeformWeight), "deformWeight");
+ dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight");
dvert->totweight = 1;
}
@@ -3558,7 +3557,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
if(dvert) {
if(!dvert->totweight) {
- dvert->dw = BLI_cellalloc_calloc(sizeof(MDeformWeight), "deformWeight");
+ dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight");
dvert->totweight = 1;
}
/* roots should be 1.0, the rest can be anything from 0.0 to 1.0 */