Index: trunk/psLib/src/astro/psSphereOps.c
===================================================================
--- trunk/psLib/src/astro/psSphereOps.c	(revision 6309)
+++ trunk/psLib/src/astro/psSphereOps.c	(revision 6534)
@@ -8,6 +8,6 @@
  *  @author Dave Robbins, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-02-02 23:19:58 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-03-07 01:53:24 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -39,31 +39,43 @@
 }
 
+static psSphereRot* sphereRotAlloc(void)
+{
+    psSphereRot *sphereRot = (psSphereRot* ) psAlloc(sizeof(psSphereRot));
+    psMemSetDeallocator(sphereRot, (psFreeFunc)sphereRotFree);
+    return (sphereRot);
+}
+
 psSphereRot* psSphereRotAlloc(double alphaP,
                               double deltaP,
                               double phiP)
 {
-    psSphereRot r,s,t;
+    psSphereRot *r = sphereRotAlloc();
+    psSphereRot *s = sphereRotAlloc();
+    psSphereRot *t = sphereRotAlloc();
+
     //The following represents: r =a rotation about the z-axis by alphaP, s =a rotation about
     // the y-axis by deltaP, and t =a rotation about the z-axis by phiP.
-    r.q0=0;
-    r.q1=0;
-    r.q2=sin(alphaP/2.0);
-    r.q3=cos(alphaP/2.0);
-
-    s.q0=0;
-    s.q1=sin(deltaP/2.0);
-    s.q2=0;
-    s.q3=cos(deltaP/2.0);
-
-    t.q0=0;
-    t.q1=0;
-    t.q2=sin(phiP/2.0);
-    t.q3=cos(phiP/2.0);
+    r->q0=0;
+    r->q1=0;
+    r->q2=sin(alphaP/2.0);
+    r->q3=cos(alphaP/2.0);
+
+    s->q0=0;
+    s->q1=sin(deltaP/2.0);
+    s->q2=0;
+    s->q3=cos(deltaP/2.0);
+
+    t->q0=0;
+    t->q1=0;
+    t->q2=sin(phiP/2.0);
+    t->q3=cos(phiP/2.0);
 
     // calculate t*s*r.
-    psSphereRot* temp = psSphereRotCombine(NULL,&t,&s);
-    psSphereRot* result = psSphereRotCombine(NULL, temp, &r);
+    psSphereRot* temp = psSphereRotCombine(NULL,t,s);
+    psSphereRot* result = psSphereRotCombine(NULL, temp, r);
     psFree(temp);
-
+    psFree(r);
+    psFree(s);
+    psFree(t);
     return result;
 }
@@ -83,6 +95,5 @@
 {
     //allocate space for a new sphere rotation and set deallocator
-    psSphereRot* rot = (psSphereRot*)psAlloc(sizeof(psSphereRot));
-    psMemSetDeallocator(rot, (psFreeFunc)sphereRotFree);
+    psSphereRot* rot = sphereRotAlloc();
 
     //The magnitude of a rotation quaternion should = 1 so we normalize here in case the
@@ -108,6 +119,5 @@
     //if output sphere rotation is NULL, allocate a new sphere rotation to return
     if (out == NULL) {
-        out = (psSphereRot* ) psAlloc(sizeof(psSphereRot));
-        psMemSetDeallocator(out, (psFreeFunc)sphereRotFree);
+        out = sphereRotAlloc();
     }
     //Since q3 is the magnitude and q0,q1,q2 are direction, the conjugate rotation
@@ -173,6 +183,5 @@
     //If output rotation is NULL, allocate a new psSphereRot to return
     if (out == NULL) {
-        out = (psSphereRot* ) psAlloc(sizeof(psSphereRot));
-        psMemSetDeallocator(out, (psFreeFunc)sphereRotFree);
+        out = sphereRotAlloc();
     }
 
