Revision: 65554
http://sourceforge.net/p/brlcad/code/65554
Author: ejno
Date: 2015-07-10 18:00:45 +0000 (Fri, 10 Jul 2015)
Log Message:
-----------
use bu_malloc()/free()
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbinsort.c
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbitmap.c
brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
Modified: brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
2015-07-10 16:46:57 UTC (rev 65553)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
2015-07-10 18:00:45 UTC (rev 65554)
@@ -453,7 +453,7 @@
chunksize = head->chunksize;
chunkperblock = head->chunkperblock;
blockrefsize = ((chunkperblock + INTPTR_BITS - 1) >> INTPTR_BITSHIFT) *
sizeof(intptr_t);
- bitsref = (intptr_t **)malloc(blockcount * (sizeof(intptr_t *) +
blockrefsize));
+ bitsref = (intptr_t **)bu_malloc(blockcount * (sizeof(intptr_t *) +
blockrefsize), "bitsref");
memset(bitsref, 0, blockcount * (sizeof(intptr_t *) + blockrefsize));
p = ADDRESS(bitsref, blockcount * sizeof(intptr_t *));
@@ -487,7 +487,7 @@
}
end:
- free(bitsref);
+ bu_free(bitsref, "bitsref");
mtSpinUnlock(&head->spinlock);
return;
Modified:
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbinsort.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbinsort.c
2015-07-10 16:46:57 UTC (rev 65553)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbinsort.c
2015-07-10 18:00:45 UTC (rev 65554)
@@ -40,6 +40,8 @@
#include "mm.h"
+#include "bu/malloc.h"
+
#include <float.h>
#include <stdlib.h>
#include <math.h>
@@ -238,7 +240,7 @@
mmBlockNodeInit(&bsort->bucketblock, numanodeindex,
sizeof(mmBinSortBucket), 1024, 1024, 0x40);
mmBlockNodeInit(&bsort->groupblock, numanodeindex,
sizeof(mmBinSortGroup) + (groupbucketcount * sizeof(mmBinSortBucket)), 16, 16,
0x40);
} else {
- bsort = (mmBinSortHead *)malloc(memsize);
+ bsort = (mmBinSortHead *)bu_malloc(memsize, "bsort");
mmBlockInit(&bsort->bucketblock, sizeof(mmBinSortBucket), 1024, 1024,
0x40);
mmBlockInit(&bsort->groupblock, sizeof(mmBinSortGroup) +
(groupbucketcount * sizeof(mmBinSortBucket)), 16, 16, 0x40);
}
@@ -285,9 +287,7 @@
if (bsort->numanodeindex >= 0)
mmNodeFree(bsort->numanodeindex, bsort, bsort->memsize);
else
- free(bsort);
-
- return;
+ bu_free(bsort, "bsort");
}
Modified:
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbitmap.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbitmap.c
2015-07-10 16:46:57 UTC (rev 65553)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmbitmap.c
2015-07-10 18:00:45 UTC (rev 65554)
@@ -40,6 +40,8 @@
#include "cc.h"
+#include "bu/malloc.h"
+
#include <limits.h>
#include <stdlib.h>
@@ -58,7 +60,7 @@
bitmap->entrycount = entrycount;
value = (initvalue & 0x1 ? ~0x0 : 0x0);
- bitmap->map = (long *)malloc(mapsize * sizeof(long));
+ bitmap->map = (long *)bu_malloc(mapsize * sizeof(long), "bitmap->map");
for (vindex = 0 ; vindex < mapsize ; vindex++)
bitmap->map[vindex] = value;
@@ -67,7 +69,7 @@
void mmBitMapFree(mmBitMap *bitmap)
{
- free(bitmap->map);
+ bu_free(bitmap->map, "bitmap->map");
bitmap->map = 0;
bitmap->mapsize = 0;
}
Modified: brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
2015-07-10 16:46:57 UTC (rev 65553)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
2015-07-10 18:00:45 UTC (rev 65554)
@@ -46,6 +46,7 @@
#include "auxiliary/mmbinsort.h"
#include "bu/log.h"
+#include "bu/malloc.h"
#include "bu/parallel.h"
#include "bu/time.h"
#include "vmath.h"
@@ -1005,7 +1006,7 @@
if (totalmemorysize > maxmemorysize)
continue;
- mesh->edgehashtable = malloc(hashmemsize);
+ mesh->edgehashtable = bu_malloc(hashmemsize, "mesh->edgehashtable");
if (mesh->edgehashtable)
break;
@@ -1018,8 +1019,7 @@
static void mdMeshHashEnd(mdMesh *mesh)
{
- free(mesh->edgehashtable);
- return;
+ bu_free(mesh->edgehashtable, "mesh->edgehashtable");
}
@@ -1092,7 +1092,7 @@
static void mdUpdateBufferInit(mdUpdateBuffer *updatebuffer, int opalloc)
{
- updatebuffer->opbuffer = (void **)malloc(opalloc * sizeof(mdOp *));
+ updatebuffer->opbuffer = (void **)bu_malloc(opalloc * sizeof(mdOp *),
"updatebuffer->opbuffer");
updatebuffer->opcount = 0;
updatebuffer->opalloc = opalloc;
#ifdef MM_ATOMIC_SUPPORT
@@ -1108,8 +1108,7 @@
#ifndef MM_ATOMIC_SUPPORT
mtSpinDestroy(&updatebuffer->spinlock);
#endif
- free(updatebuffer->opbuffer);
- return;
+ bu_free(updatebuffer->opbuffer, "updatebuffer->opbuffer");
}
static void mdUpdateBufferAdd(mdUpdateBuffer *updatebuffer, mdOp *op, int
orflags)
@@ -1884,7 +1883,7 @@
buffer->vertexalloc = MD_LOCK_BUFFER_STATIC;
if (maxvertexcount > MD_LOCK_BUFFER_STATIC) {
- buffer->vertexlist = (mdi *)malloc(maxvertexcount * sizeof(mdi));
+ buffer->vertexlist = (mdi *)bu_malloc(maxvertexcount * sizeof(mdi),
"buffer->vertexlist");
buffer->vertexalloc = maxvertexcount;
}
@@ -1898,13 +1897,13 @@
mdi *vertexlist;
if (maxvertexcount > buffer->vertexalloc) {
- vertexlist = (mdi *)malloc(maxvertexcount * sizeof(mdi));
+ vertexlist = (mdi *)bu_malloc(maxvertexcount * sizeof(mdi),
"vertexlist");
for (vindex = 0 ; vindex < buffer->vertexcount ; vindex++)
vertexlist[vindex] = buffer->vertexlist[vindex];
if (buffer->vertexlist != buffer->vertexstatic)
- free(buffer->vertexlist);
+ bu_free(buffer->vertexlist, "buffer->vertexlist");
buffer->vertexlist = vertexlist;
buffer->vertexalloc = maxvertexcount;
@@ -1916,7 +1915,7 @@
static inline void mdLockBufferEnd(mdLockBuffer *buffer)
{
if (buffer->vertexlist != buffer->vertexstatic)
- free(buffer->vertexlist);
+ bu_free(buffer->vertexlist, "buffer->vertexlist");
buffer->vertexlist = buffer->vertexstatic;
buffer->vertexalloc = MD_LOCK_BUFFER_STATIC;
@@ -2316,7 +2315,7 @@
trireflist = trirefstatic;
if (trirefmax > MD_EDGE_COLLAPSE_TRIREF_STATIC)
- trireflist = (mdi *)malloc(trirefmax * sizeof(mdi));
+ trireflist = (mdi *)bu_malloc(trirefmax * sizeof(mdi), "trireflist");
/* Update all triangles connected to vertex0 and vertex1 */
trirefstore = trireflist;
@@ -2369,7 +2368,7 @@
/* If buffer wasn't static, free it */
if (trireflist != trirefstatic)
- free(trireflist);
+ bu_free(trireflist, "trireflist");
/* Verify if we should create new ops between newv and outer vertices of
deleted triangles */
mdEdgeCollapseLinkOuter(mesh, tdata, newv, outer0);
@@ -2512,10 +2511,10 @@
/* Allocate space for per-vertex lists of face references, including
future vertices */
mesh->trirefcount = 0;
mesh->trirefalloc = 2 * 6 * mesh->tricount;
- mesh->trireflist = (mdi *)malloc(mesh->trirefalloc * sizeof(mdi));
+ mesh->trireflist = (mdi *)bu_malloc(mesh->trirefalloc * sizeof(mdi),
"mesh->trireflist");
/* Allocate triangles */
- mesh->trilist = (mdTriangle *)malloc(mesh->tricount * sizeof(mdTriangle));
+ mesh->trilist = (mdTriangle *)bu_malloc(mesh->tricount *
sizeof(mdTriangle), "mesh->trilist");
/* Allocate edge hash table */
retval = 1;
@@ -2758,9 +2757,8 @@
mtSpinDestroy(&mesh->globalvertexspinlock);
#endif
mmAlignFree(mesh->vertexlist);
- free(mesh->trireflist);
- free(mesh->trilist);
- return;
+ bu_free(mesh->trireflist, "mesh->trireflist");
+ bu_free(mesh->trilist, "mesh->trilist");
}
@@ -3514,8 +3512,8 @@
/* Count triangles and assign redirectindex to each in sequence */
mdMeshPackCountTriangles(mesh);
- mesh->vertexnormal = malloc(mesh->vertexalloc * 3 * sizeof(normal));
- mesh->trinormal = malloc(mesh->tripackcount * sizeof(mdTriNormal));
+ mesh->vertexnormal = bu_malloc(mesh->vertexalloc * 3 * sizeof(normal),
"mesh->vertexnormal");
+ mesh->trinormal = bu_malloc(mesh->tripackcount * sizeof(mdTriNormal),
"mesh->trinormal");
/* Build up mesh->trinormal, store normals, area and vertex angles of each
triangle */
mdMeshBuildTriangleNormals(mesh);
@@ -3537,10 +3535,8 @@
mdMeshWriteVertices(mesh, normalattrib, (mdf *)mesh->vertexnormal);
mdMeshWriteIndices(mesh);
- free(mesh->vertexnormal);
- free(mesh->trinormal);
-
- return;
+ bu_free(mesh->vertexnormal, "mesh->vertexnormal");
+ bu_free(mesh->trinormal, "mesh->trinormal");
}
Modified: brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
2015-07-10 16:46:57 UTC (rev 65553)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
2015-07-10 18:00:45 UTC (rev 65554)
@@ -43,6 +43,7 @@
#include "auxiliary/math3d.h"
#include "bu/log.h"
+#include "bu/malloc.h"
#include "bu/parallel.h"
#include <stdlib.h>
@@ -1560,7 +1561,7 @@
mesh.vertexlist = (moVertex *)mmAlignAlloc(mesh.vertexcount *
sizeof(moVertex), 0x40);
mesh.trilist = (moTriangle *)mmAlignAlloc(mesh.tricount *
sizeof(moTriangle), 0x40);
mesh.trirefcount = 0;
- mesh.trireflist = (moi *)malloc(3 * mesh.tricount * sizeof(moi));
+ mesh.trireflist = (moi *)bu_malloc(3 * mesh.tricount * sizeof(moi),
"mesh.trireflist");
/* Launch threads! */
tinit = threadinit;
@@ -1591,11 +1592,10 @@
/* Free all global data */
mmAlignFree(mesh.vertexlist);
mmAlignFree(mesh.trilist);
- free(mesh.trireflist);
+ bu_free(mesh.trireflist, "mesh.trireflist");
moBarrierDestroy(&mesh.workbarrier);
moBarrierDestroy(&mesh.globalbarrier);
-
return 1;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits