-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3693: Compile natives as C instead of C++, check malloc/calloc retur…
…n values for null
- Loading branch information
Showing
11 changed files
with
121 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This header contains functions to be shared between both native libraries | ||
|
||
#include <jni.h> | ||
|
||
#ifndef _INCLUDE_SHARED_H | ||
#define _INCLUDE_SHARED_H | ||
|
||
void throwOutOfMemoryError(JNIEnv* env, const char* msg); | ||
|
||
#endif |
2 changes: 1 addition & 1 deletion
2
native/src/main/java/net/md_5/bungee/jni/NativeCodeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters