I replaced calls to malloc() and free() in jcl.c and native_state.c with
the corresponding target macros for improved portability.
2006-01-17 Roman Kennke <[EMAIL PROTECTED]>
* native/jni/classpath/jcl.c:
(JCL_malloc): Replaced calls to malloc with the corresponding
target layer macro.
(JCL_free): Replaced calls to free with the corresponding
target layer macro.
* native/jni/classpath/native_state.c:
(cp_gtk_init_state_table_with_size): Replaced calls to malloc and
calloc with the corresponding target layer macro.
(remove_node): Replaced calls to free with the corresponding
target layer macro.
(add_node): Replaced calls to malloc with the corresponding
target layer macro.
/Roman
Index: native/jni/classpath/jcl.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/classpath/jcl.c,v
retrieving revision 1.20
diff -u -r1.20 jcl.c
--- native/jni/classpath/jcl.c 17 Jan 2006 12:29:39 -0000 1.20
+++ native/jni/classpath/jcl.c 17 Jan 2006 14:05:07 -0000
@@ -95,7 +95,8 @@
JNIEXPORT void *JNICALL
JCL_malloc (JNIEnv * env, size_t size)
{
- void *mem = malloc (size);
+ void *mem;
+ TARGET_NATIVE_MEMORY_ALLOC(mem,void *,size);
if (mem == NULL)
{
JCL_ThrowException (env, "java/lang/OutOfMemoryError",
@@ -133,7 +134,7 @@
{
if (p != NULL)
{
- free (p);
+ TARGET_NATIVE_MEMORY_FREE (p);
}
}
Index: native/jni/classpath/native_state.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/classpath/native_state.c,v
retrieving revision 1.12
diff -u -r1.12 native_state.c
--- native/jni/classpath/native_state.c 25 Jul 2005 22:32:51 -0000 1.12
+++ native/jni/classpath/native_state.c 17 Jan 2006 14:05:07 -0000
@@ -36,8 +36,11 @@
exception statement from your version. */
#include <stdlib.h>
-#include <assert.h>
#include <jni.h>
+
+#include "target_native.h"
+#include "target_native_memory.h"
+
#include "native_state.h"
#define DEFAULT_TABLE_SIZE 97
@@ -57,10 +60,21 @@
if (clazz_g == NULL)
return NULL;
- table = (struct state_table *) malloc (sizeof (struct state_table));
+ TARGET_NATIVE_MEMORY_ALLOC(table,struct state_table *,
+ sizeof(struct state_table));
+ if (table == NULL)
+ return NULL;
+
table->size = size;
- table->head = (struct state_node **) calloc (sizeof (struct state_node *),
- table->size);
+ TARGET_NATIVE_MEMORY_ALLOC(table->head,struct state_node **,
+ sizeof(struct state_node *)*table->size);
+ if (table->head == NULL)
+ {
+ TARGET_NATIVE_MEMORY_FREE(table);
+ return NULL;
+ }
+ TARGET_NATIVE_MEMORY_FILL(table->head,0,
+ sizeof(struct state_node *) * table->size);
table->hash = hash;
table->clazz = clazz_g;
@@ -89,7 +103,7 @@
else
back_ptr->next = node->next;
return_value = node->c_state;
- free (node);
+ TARGET_NATIVE_MEMORY_FREE(node);
return return_value;
}
back_ptr = node;
@@ -159,7 +173,11 @@
}
}
- new_node = (struct state_node *) malloc (sizeof (struct state_node));
+ TARGET_NATIVE_MEMORY_ALLOC(new_node,struct state_node *,
+ sizeof(struct state_node));
+ if (new_node == NULL)
+ return;
+
new_node->key = obj_id;
new_node->c_state = state;
new_node->next = *head;
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches