#3693: Compile natives as C instead of C++, check malloc/calloc return values for null
This commit is contained in:
15
native/src/main/c/shared.c
Normal file
15
native/src/main/c/shared.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "shared.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void throwOutOfMemoryError(JNIEnv* env, const char* msg) {
|
||||
jclass exceptionClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
|
||||
if (!exceptionClass) {
|
||||
// If the proxy ran out of memory, loading this class may fail
|
||||
fprintf(stderr, "OUT OF MEMORY: %s\n", msg);
|
||||
fprintf(stderr, "Could not load class java.lang.OutOfMemoryError!\n");
|
||||
exit(-1);
|
||||
return;
|
||||
}
|
||||
(*env)->ThrowNew(env, exceptionClass, msg);
|
||||
}
|
Reference in New Issue
Block a user