diff options
author | Roman Kennke <roman@kennke.org> | 2006-01-17 12:29:38 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-01-17 12:29:38 +0000 |
commit | 88368b65b491556d2596cc366fb3890277cb164a (patch) | |
tree | 05d34a28dff383f312ae83c3982c92aa7f21a8af /native/jni/classpath | |
parent | 745afe139667f48282bebcac854561f1113beb67 (diff) | |
download | classpath-88368b65b491556d2596cc366fb3890277cb164a.tar.gz |
2006-01-17 Roman Kennke <kennke@aicas.com>
* native/jni/classpath/jcl.c: Added missing imports.
(JCL_realloc): Fixed signature to include oldsize. This is needed
for some targets. Make this function use the MEMORY_REALLOC macro
for portability.
* native/jni/classpath/jcl.h
(JCL_realloc): Adjusted signature.
* native/jni/java-io/java_io_VMFile.c:
(Java_java_io_VMFile_create): Use target layer macro for handling
errno, for portability.
(Java_java_io_VMFile_length): Release filename string in error cases
before returning.
(Java_java_io_VMFile_list): Initialize filename variable. Use new
version of JCL_realloc.
* native/jni/java-net/java_net_VMInetAddress.c:
(Java_java_net_VMInetAddress_getHostByName): Use renamed macro
TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_BY_NAME.
* native/jni/java-net/javanet.c:
(_javanet_bind): Make errorstr variable const to avoid compiler
warning.
(_javanet_set_option): Fixed typo.
(_javanet_get_option): Fixed typo.
* native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c:
(Java_gnu_java_nio_channels_FileChannelImpl_open): Made
error_string variable const to avoid compiler warning.
* native/target/generic/target_generic_file.h:
Replaced // comments with /* */ comments to avoid compiler warnings.
Added some spaces to make code better readable.
* native/target/generic/target_generic_memory.h:
Replaced // comments with /* */ comments to avoid compiler warnings.
* native/target/generic/target_generic_misc.c:
Removed unused TARGET_NATIVE_MISC_FORMAT_STRING macro. This caused
compiler warnings due to use of varargs.
* native/target/generic/target_generic_misc.h:
Removed unused TARGET_NATIVE_MISC_FORMAT_STRING macro. This caused
compiler warnings due to use of varargs.
* native/target/generic/target_generic_network.h:
Replaced // comments with /* */ comments to avoid compiler warnings.
(targetGenericNetwork_receive): Fixed signature to use signed chars
for buffer parameter to avoid warning when passing a jbyte to the
function.
Diffstat (limited to 'native/jni/classpath')
-rw-r--r-- | native/jni/classpath/jcl.c | 25 | ||||
-rw-r--r-- | native/jni/classpath/jcl.h | 3 |
2 files changed, 23 insertions, 5 deletions
diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c index dd6ca06a7..d3530c3b3 100644 --- a/native/jni/classpath/jcl.c +++ b/native/jni/classpath/jcl.c @@ -40,8 +40,15 @@ exception statement from your version. */ #include <stdlib.h> #include <stdio.h> + +#include "target_native.h" +#include "target_native_io.h" +#include "target_native_memory.h" +#include "target_native_misc.h" + #include <jcl.h> + #ifndef __GNUC__ #ifndef __attribute__ #define __attribute__(x) /* nothing */ @@ -98,17 +105,27 @@ JCL_malloc (JNIEnv * env, size_t size) return mem; } +/* The __attribute__((__unused__)) for oldsize is kind of a hack that is + * necessary to make the compiler silent. However, the problem is that we + * don't know if the parameter is used or not, this depends on which target + * we compile for. TARGET_NATIVE_MEMORY_REALLOC may or may not use this + * parameter. This problem will hopefully be solved when we switch the target + * native layer to using functions instead of macros. */ JNIEXPORT void *JNICALL -JCL_realloc (JNIEnv * env, void *ptr, size_t size) +JCL_realloc (JNIEnv * env, void *ptr, + size_t oldsize __attribute__((__unused__)), size_t newsize) { - ptr = realloc (ptr, size); - if (ptr == 0) + void *newptr; + + TARGET_NATIVE_MEMORY_REALLOC(ptr, newptr, void*, oldsize, newsize); + if (newptr == 0) { JCL_ThrowException (env, "java/lang/OutOfMemoryError", "malloc() failed."); return NULL; } - return (ptr); + + return newptr; } JNIEXPORT void JNICALL diff --git a/native/jni/classpath/jcl.h b/native/jni/classpath/jcl.h index 25662c06b..fc01612d1 100644 --- a/native/jni/classpath/jcl.h +++ b/native/jni/classpath/jcl.h @@ -55,7 +55,8 @@ JNIEXPORT void JNICALL JCL_ThrowException (JNIEnv * env, const char *className, const char *errMsg); JNIEXPORT void *JNICALL JCL_malloc (JNIEnv * env, size_t size); -JNIEXPORT void *JNICALL JCL_realloc (JNIEnv * env, void *ptr, size_t size); +JNIEXPORT void *JNICALL JCL_realloc (JNIEnv * env, void *ptr, size_t oldsize, + size_t newsize); JNIEXPORT void JNICALL JCL_free (JNIEnv * env, void *p); JNIEXPORT const char *JNICALL JCL_jstring_to_cstring (JNIEnv * env, jstring s); |