Skip to content

Commit

Permalink
Use Py_ssize_t when calculate buffer len (#145)
Browse files Browse the repository at this point in the history
Also fix the pointer to long conversions
that clang 15 considers error by default
on MacOS M2
  • Loading branch information
jmao-denver authored May 6, 2024
1 parent ef64965 commit 6c78a2f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/c/jni/org_jpy_PyLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ jlong JNICALL Java_org_jpy_PyLib_executeCode
codeChars = (*jenv)->GetStringUTFChars(jenv, jCode, NULL);
if (codeChars == NULL) {
PyLib_ThrowOOM(jenv);
return NULL;
return 0;
}

JPy_DIAG_PRINT(JPy_DIAG_F_EXEC, "Java_org_jpy_PyLib_executeCode: code='%s'\n", codeChars);
Expand Down
2 changes: 1 addition & 1 deletion src/main/c/jpy_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ PyTypeObject Diag_Type =
sizeof (JPy_Diag), /* tp_basicsize */
0, /* tp_itemsize */
NULL, /* tp_dealloc */
NULL, /* tp_print */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_reserved */
Expand Down
2 changes: 1 addition & 1 deletion src/main/c/jpy_jarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int JArray_GetBufferProc(JPy_JArray* self, Py_buffer* view, int flags, char java

// Step 2/5
view->buf = buf;
view->len = itemCount * itemSize;
view->len = (Py_ssize_t)itemCount * (Py_ssize_t)itemSize;
view->itemsize = itemSize;
view->readonly = (flags & (PyBUF_WRITE | PyBUF_WRITEABLE)) == 0;
self->bufReadonly &= view->readonly;
Expand Down
2 changes: 1 addition & 1 deletion src/main/c/jpy_jfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ PyTypeObject JField_Type = {
sizeof (JPy_JField), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)JField_dealloc, /* tp_dealloc */
NULL, /* tp_print */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_reserved */
Expand Down
4 changes: 2 additions & 2 deletions src/main/c/jpy_jmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ PyTypeObject JMethod_Type = {
sizeof (JPy_JMethod), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)JMethod_dealloc, /* tp_dealloc */
NULL, /* tp_print */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_reserved */
Expand Down Expand Up @@ -1036,7 +1036,7 @@ PyTypeObject JOverloadedMethod_Type = {
sizeof (JPy_JOverloadedMethod), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)JOverloadedMethod_dealloc, /* tp_dealloc */
NULL, /* tp_print */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_reserved */
Expand Down
2 changes: 1 addition & 1 deletion src/main/c/jpy_jtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2578,7 +2578,7 @@ PyTypeObject JType_Type = {
sizeof (JPy_JType), /* tp_basicsize */
0, /* tp_itemsize */
(destructor) JType_dealloc, /* tp_dealloc */
NULL, /* tp_print */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_reserved */
Expand Down
2 changes: 1 addition & 1 deletion src/main/c/jpy_verboseexcept.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PyTypeObject VerboseExceptions_Type =
sizeof (VerboseExceptions_Type), /* tp_basicsize */
0, /* tp_itemsize */
NULL, /* tp_dealloc */
NULL, /* tp_print */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_reserved */
Expand Down

0 comments on commit 6c78a2f

Please sign in to comment.