Consistent memory intiailization between C and C++ in typemaps
Remove unnecessary initialization via calloc calls and replace with malloc.
This commit is contained in:
parent
00a9b8d3af
commit
cd04b372a4
2 changed files with 5 additions and 5 deletions
|
|
@ -52,7 +52,7 @@ static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **ca
|
|||
#ifdef __cplusplus
|
||||
%{ *carr = new CTYPE[sz]; %}
|
||||
#else
|
||||
%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %}
|
||||
%{ *carr = (CTYPE*) malloc(sz * sizeof(CTYPE)); %}
|
||||
#endif
|
||||
%{ if (!*carr) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
|
||||
|
|
@ -259,7 +259,7 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] *
|
|||
#ifdef __cplusplus
|
||||
$1 = new $*1_ltype[sz];
|
||||
#else
|
||||
$1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
|
||||
$1 = ($1_ltype) malloc(sz * sizeof($*1_ltype));
|
||||
#endif
|
||||
if (!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
|
||||
|
|
@ -289,7 +289,7 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] *
|
|||
#ifdef __cplusplus
|
||||
$1 = new $*1_ltype[sz];
|
||||
#else
|
||||
$1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
|
||||
$1 = ($1_ltype) malloc(sz * sizeof($*1_ltype));
|
||||
#endif
|
||||
if (!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#ifdef __cplusplus
|
||||
$1 = new char*[size+1];
|
||||
#else
|
||||
$1 = (char **)calloc(size+1, sizeof(char *));
|
||||
$1 = (char **)malloc((size+1) * sizeof(char *));
|
||||
#endif
|
||||
for (i = 0; i<size; i++) {
|
||||
jstring j_string = (jstring)JCALL2(GetObjectArrayElement, jenv, $input, i);
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
#ifdef __cplusplus
|
||||
$1[i] = new char [strlen(c_string)+1];
|
||||
#else
|
||||
$1[i] = (char *)calloc(strlen(c_string)+1, sizeof(const char *));
|
||||
$1[i] = (char *)malloc((strlen(c_string)+1) * sizeof(const char *));
|
||||
#endif
|
||||
strcpy($1[i], c_string);
|
||||
JCALL2(ReleaseStringUTFChars, jenv, j_string, c_string);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue