The part of the code that is causing this error is: -
newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
-
I have tried to undefined the variable and malloc. I am not sure how to correct the error.
Also I am compiling this to with the ILE C AS400 compiler
The following is the entire 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;
-
}
-
1 3109
update: I found the solution........ inside ctype.h file I defined the struct as an int "#define objectint(b) *(uint8_t*)&b" and then I went to the offending line of code and change "newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));" to "objectint(newobj) = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));"
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt Feinstein |
last post by:
Hi all--
I'm new to Python, and was somewhat taken aback to discover that the
core language lacks some basic numerical types (e.g., single-precision
float, short integers). I realize that there...
|
by: Gonçalo Rodrigues |
last post by:
Hi all,
I have a few questions on primitive types that I will divide in two
main questions. I realize that some of these questions -- especially
2. below -- are not directly related to C++ as a...
|
by: aruna |
last post by:
Why division/mulitiplication/addition of pointers are not
allowed in C?
|
by: GS |
last post by:
The stdint.h header definition mentions five integer categories,
1) exact width, eg., int32_t
2) at least as wide as, eg., int_least32_t
3) as fast as possible but at least as wide as, eg.,...
|
by: Herby |
last post by:
I need to define my own types and arrays of these types.
These types are for the most part extensions of the built in types and
need to provide all the basic operations of arithmetic and...
|
by: miked |
last post by:
Why are there still no covariant return types?
All searches reveal no workarounds accept for using an interface which is a
real pain. I wind up missing this capability almost every time I...
|
by: carsonbj |
last post by:
I have an issue where the below operation works on a little-endian
architecture but not on a big-endian architecture. I was under the
impression that pointer arithmetic is architecture independant...
|
by: jacob navia |
last post by:
Hi people
I have been working again in my tutorial, and I have finished the
"types" chapter. If you feel like "jacob bashing" this is the
occasion! I am asking for criticisms, or for things I may...
|
by: jehugaleahsa |
last post by:
Hello:
Today I learned that the + operator cannot be passed a delegate. I get
an error from the CLR saying I have an invalid program.
With that, I was wondering if someone could tell me what...
|
by: nbiswas |
last post by:
Welcome to the lesson on R data structures.
To perform any meaningful data analysis we need to collect our data into R data structures.
In this lesson we will explore the most frequently used...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |