Author: spouliot
Date: 2007-10-03 17:43:58 -0400 (Wed, 03 Oct 2007)
New Revision: 86834
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/array.cpp
Log:
array.cpp: Move double array allocations back to new/delete.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-10-03 21:00:05 UTC (rev 86833)
+++ trunk/moon/src/ChangeLog 2007-10-03 21:43:58 UTC (rev 86834)
@@ -1,3 +1,7 @@
+2007-10-03 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * array.cpp: Move double array allocations back to new/delete.
+
2007-10-03 Jeffrey Stedfast <[EMAIL PROTECTED]>
* font.cpp (EmSize): Removed, not needed.
Modified: trunk/moon/src/array.cpp
===================================================================
--- trunk/moon/src/array.cpp 2007-10-03 21:00:05 UTC (rev 86833)
+++ trunk/moon/src/array.cpp 2007-10-03 21:43:58 UTC (rev 86834)
@@ -49,7 +49,7 @@
{
int n = 16;
int pos = 0;
- double *doubles = (double*)g_malloc (n * sizeof (double));
+ double *doubles = new double [n];
char *start = (char*)s;
char *end = NULL;
@@ -71,8 +71,12 @@
if (errno != 0 || (start == end))
goto error;
if (pos == n) {
- n <<= 1; // double array size
- doubles = (double*)g_realloc (doubles, n *
sizeof (double));
+ int new_size = n << 1; // double array size
+ double *newdoubles = new double [new_size];
+ memcpy (newdoubles, doubles, n * sizeof
(double));
+ delete[] doubles;
+ doubles = newdoubles;
+ n = new_size;
}
doubles[pos++] = dv;
}
@@ -81,7 +85,7 @@
*count = pos;
return doubles;
error:
- g_free (doubles);
+ delete [] doubles;
*count = 0;
return NULL;
}
@@ -95,7 +99,7 @@
p->basic.refcount = 1;
memcpy (p->points, points, sizeof (Point) * count);
return p;
-};
+}
Point *
@@ -109,7 +113,7 @@
}
// invalid if doubles are not in pair
if ((n & 1) == 1) {
- g_free (doubles);
+ delete [] doubles;
*count = 0;
return NULL;
}
@@ -120,7 +124,7 @@
points[j].x = doubles [i++];
points[j].y = doubles [i++];
}
- g_free (doubles);
+ delete [] doubles;
*count = n;
return points;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches