ALLOCA instead of alloca

Irrisor <[email protected]>
Newsgroups gmane.comp.lib.ode
Message-ID <[email protected]>
Hi again,

just a quick note: I found some usages of alloca in collision_space.cpp and 
quickstep.cpp. These might be changed to ALLOCA to be consistent with the rest.
Patch attached, if anyone cares to apply it.

Best regards,
Irrisor

_______________________________________________
ODE mailing list
[email protected]
http://ode.org/mailman/listinfo/ode
alloca.patch (text/plain, 3.4 KB)
Index: ode/src/collision_space.cpp
===================================================================
--- ode/src/collision_space.cpp	(revision 1261)
+++ ode/src/collision_space.cpp	(working copy)
@@ -498,7 +498,7 @@
   // have been intersection-tested against each other yet. this array can
   // grow large with high n, but oh well...
   int tested_rowsize = (n+7) >> 3;	// number of bytes needed for n bits
-  unsigned char *tested = (unsigned char *) alloca (n * tested_rowsize);
+  unsigned char *tested = (unsigned char *) ALLOCA (n * tested_rowsize);
   memset (tested,0,n * tested_rowsize);
 
   // create a hash table to store all AABBs. each AABB may take up to 8 cells.
@@ -525,7 +525,7 @@
 	  // get the hash index
 	  unsigned long hi = getVirtualAddress (aabb->level,xi,yi,zi) % sz;
 	  // add a new node to the hash table
-	  Node *node = (Node*) alloca (sizeof (Node));
+	  Node *node = (Node*) ALLOCA (sizeof (Node));
 	  node->x = xi;
 	  node->y = yi;
 	  node->z = zi;
Index: ode/src/quickstep.cpp
===================================================================
--- ode/src/quickstep.cpp	(revision 1261)
+++ ode/src/quickstep.cpp	(working copy)
@@ -406,7 +406,7 @@
 	}
 
 	// order to solve constraint rows in
-	IndexError *order = (IndexError*) alloca (m*sizeof(IndexError));
+	IndexError *order = (IndexError*) ALLOCA (m*sizeof(IndexError));
 
 #ifndef REORDER_CONSTRAINTS
 	// make sure constraints with findex < 0 come first.
@@ -572,7 +572,7 @@
 	// (the "dxJoint *const*" declaration says we're allowed to modify the joints
 	// but not the joint array, because the caller might need it unchanged).
 	//@@@ do we really need to do this? we'll be sorting constraint rows individually, not joints
-	dxJoint **joint = (dxJoint**) alloca (nj * sizeof(dxJoint*));
+	dxJoint **joint = (dxJoint**) ALLOCA (nj * sizeof(dxJoint*));
 	memcpy (joint,_joint,nj * sizeof(dxJoint*));
 
 	// for all bodies, compute the inertia tensor and its inverse in the global
@@ -612,7 +612,7 @@
 	// joints with m=0 are inactive and are removed from the joints array
 	// entirely, so that the code that follows does not consider them.
 	//@@@ do we really need to save all the info1's
-	dxJoint::Info1 *info = (dxJoint::Info1*) alloca (nj*sizeof(dxJoint::Info1));
+	dxJoint::Info1 *info = (dxJoint::Info1*) ALLOCA (nj*sizeof(dxJoint::Info1));
 	for (i=0, j=0; j<nj; j++) {	// i=dest, j=src
 		joint[j]->vtable->getInfo1 (joint[j],info+i);
 		dIASSERT (info[i].m >= 0 && info[i].m <= 6 && info[i].nub >= 0 && info[i].nub <= info[i].m);
@@ -625,7 +625,7 @@
 
 	// create the row offset array
 	int m = 0;
-	int *ofs = (int*) alloca (nj*sizeof(int));
+	int *ofs = (int*) ALLOCA (nj*sizeof(int));
 	for (i=0; i<nj; i++) {
 		ofs[i] = m;
 		m += info[i].m;
@@ -633,7 +633,7 @@
 
 	// if there are constraints, compute the constraint force
 	dRealAllocaArray (J,m*12);
-	int *jb = (int*) alloca (m*2*sizeof(int));
+	int *jb = (int*) ALLOCA (m*2*sizeof(int));
 	if (m > 0) {
 		// create a constraint equation right hand side vector `c', a constraint
 		// force mixing vector `cfm', and LCP low and high bound vectors, and an
@@ -642,7 +642,7 @@
 		dRealAllocaArray (cfm,m);
 		dRealAllocaArray (lo,m);
 		dRealAllocaArray (hi,m);
-		int *findex = (int*) alloca (m*sizeof(int));
+		int *findex = (int*) ALLOCA (m*sizeof(int));
 		dSetZero (c,m);
 		dSetValue (cfm,m,world->global_cfm);
 		dSetValue (lo,m,-dInfinity);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.