The part of the code that is causing this error is:
Code:
newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
I have tried to undefine the variable and malloc.
I am not sure how to correct the error.
Also I am compiling this with the ILE C AS400 compiler
The following is the entire code.....
Code:
- /* NOTE: this API is -ONLY- for use with single byte character strings. */
- /* Do not use it with Unicode. */
- #include "bytes_methods.h"
- #include "structmember.h"
- #include "stdlib.h"
- #include "Python.h"
- #include "stdio.h"
- #include "string.h"
- static PyObject*
- stringlib_isspace(PyObject *self)
- {
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- return _Py_bytes_isspace(sum, STRINGLIB_LEN(self));
- }
- static PyObject*
- stringlib_isalpha(PyObject *self)
- {
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- return _Py_bytes_isalpha(sum, STRINGLIB_LEN(self));
- }
- static PyObject*
- stringlib_isalnum(PyObject *self)
- {
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- return _Py_bytes_isalnum(sum, STRINGLIB_LEN(self));
- }
- static PyObject*
- stringlib_isdigit(PyObject *self)
- {
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- return _Py_bytes_isdigit(sum, STRINGLIB_LEN(self));
- }
- static PyObject*
- stringlib_islower(PyObject *self)
- {
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- return _Py_bytes_islower(sum, STRINGLIB_LEN(self));
- }
- static PyObject*
- stringlib_isupper(PyObject *self)
- {
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- return _Py_bytes_isupper(sum, STRINGLIB_LEN(self));
- }
- static PyObject*
- stringlib_istitle(PyObject *self)
- {
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- return _Py_bytes_istitle(sum, STRINGLIB_LEN(self));
- }
- /* functions that return a new object partially translated by ctype funcs: */
- static PyObject*
- stringlib_lower(PyObject *self)
- {
- char* sum1;
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- PyObject* newobj;
- newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
- sum1 = (char*)malloc(STRINGLIB_STR(newobj));
- if (!newobj)
- return NULL;
- _Py_bytes_lower(sum1, sum,
- STRINGLIB_LEN(self));
- return newobj;
- }
- static PyObject*
- stringlib_upper(PyObject *self)
- {
- char* sum1;
- const char* sum = (const char*)malloc(STRINGLIB_STR(self));
- PyObject* newobj;
- newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
- sum1 = (char*)malloc(STRINGLIB_STR(newobj));
- if (!newobj)
- return NULL;
- _Py_bytes_upper(sum1, sum,
- STRINGLIB_LEN(self));
- return newobj;
- }
- static PyObject*
- stringlib_title(PyObject *self)
- {
- char* sum1;
- char* sum = (char*)malloc(STRINGLIB_STR(self));
- PyObject* newobj;
- newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
- sum1 = (char*)realloc(sum,STRINGLIB_STR(newobj));
- if (!newobj)
- return NULL;
- _Py_bytes_title(sum1,sum,
- STRINGLIB_LEN(self));
- return newobj;
- }
- static PyObject*
- stringlib_capitalize(PyObject *self)
- {
- char* sum1;
- char* sum = (char*)malloc(STRINGLIB_STR(self));
- PyObject* newobj;
- newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
- if (!newobj)
- return NULL;
- sum1 = (char*)realloc(sum,STRINGLIB_STR(newobj));
- _Py_bytes_capitalize(sum1, sum,
- STRINGLIB_LEN(self));
- return newobj;
- }
- static PyObject*
- stringlib_swapcase(PyObject *self)
- {
- char* sum1;
- char* sum = (char *)malloc(STRINGLIB_STR(self));
- PyObject* newobj;
- newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
- sum1 = (char*)realloc(sum,STRINGLIB_STR(newobj));
- if (!newobj)
- return NULL;
- free (sum);
- _Py_bytes_swapcase(sum1,sum,
- STRINGLIB_LEN(self));
- return newobj;
- }