diff options
author | Roman Kennke <roman@kennke.org> | 2006-01-17 14:10:24 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-01-17 14:10:24 +0000 |
commit | 8f3fad28b4ca826b1a82724334d366df73941b78 (patch) | |
tree | 7a55d3cf21ca558a93225055ff851825f1b4701b /native | |
parent | 71a088c04007ad6f4a6d0abf6f4366032d21c55f (diff) | |
download | classpath-8f3fad28b4ca826b1a82724334d366df73941b78.tar.gz |
2006-01-17 Roman Kennke <kennke@aicas.com>
* 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.
Diffstat (limited to 'native')
-rw-r--r-- | native/jni/classpath/jcl.c | 5 | ||||
-rw-r--r-- | native/jni/classpath/native_state.c | 30 |
2 files changed, 27 insertions, 8 deletions
diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c index d3530c3b3..ec1dfe1b8 100644 --- a/native/jni/classpath/jcl.c +++ b/native/jni/classpath/jcl.c @@ -95,7 +95,8 @@ JCL_ThrowException (JNIEnv * env, const char *className, const char *errMsg) 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 @@ JCL_free (JNIEnv * env __attribute__ ((unused)), void *p) { if (p != NULL) { - free (p); + TARGET_NATIVE_MEMORY_FREE (p); } } diff --git a/native/jni/classpath/native_state.c b/native/jni/classpath/native_state.c index 2cb43d614..4124ae131 100644 --- a/native/jni/classpath/native_state.c +++ b/native/jni/classpath/native_state.c @@ -36,8 +36,11 @@ obligated to do so. If you do not wish to do so, delete this 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 @@ cp_gtk_init_state_table_with_size (JNIEnv * env, jclass clazz, jint size) 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 @@ remove_node (struct state_node **head, jint obj_id) 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 @@ add_node (struct state_node **head, jint obj_id, void *state) } } - 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; |