Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pandas/_libs/src/parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int parser_init(parser_t *self) {
self->warn_msg = NULL;

// token stream
self->stream = malloc(STREAM_INIT_SIZE * sizeof(char));
self->stream = malloc(STREAM_INIT_SIZE);
if (self->stream == NULL) {
parser_cleanup(self);
return PARSER_OUT_OF_MEMORY;
Expand Down Expand Up @@ -221,9 +221,8 @@ static int make_stream_space(parser_t *self, size_t nbytes) {
char *orig_ptr = (void *)self->stream;
TRACE(("\n\nmake_stream_space: nbytes = %zu. grow_buffer(self->stream...)\n",
nbytes))
self->stream =
(char *)grow_buffer((void *)self->stream, self->stream_len,
&self->stream_cap, nbytes * 2, sizeof(char), &status);
self->stream = (char *)grow_buffer((void *)self->stream, self->stream_len,
&self->stream_cap, nbytes * 2, 1, &status);
TRACE(("make_stream_space: self->stream=%p, self->stream_len = %zu, "
"self->stream_cap=%zu, status=%zu\n",
self->stream, self->stream_len, self->stream_cap, status))
Expand Down
22 changes: 11 additions & 11 deletions pandas/_libs/src/vendored/ujson/python/objToJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ static char *List_iterGetName(JSOBJ Py_UNUSED(obj),
//=============================================================================
static void Index_iterBegin(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
GET_TC(tc)->index = 0;
GET_TC(tc)->cStr = PyObject_Malloc(20 * sizeof(char));
GET_TC(tc)->cStr = PyObject_Malloc(20);
if (!GET_TC(tc)->cStr) {
PyErr_NoMemory();
}
Expand All @@ -998,10 +998,10 @@ static int Index_iterNext(JSOBJ obj, JSONTypeContext *tc) {
const Py_ssize_t index = GET_TC(tc)->index;
Py_XDECREF(GET_TC(tc)->itemValue);
if (index == 0) {
memcpy(GET_TC(tc)->cStr, "name", sizeof(char) * 5);
memcpy(GET_TC(tc)->cStr, "name", 5);
GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "name");
} else if (index == 1) {
memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
memcpy(GET_TC(tc)->cStr, "data", 5);
GET_TC(tc)->itemValue = get_values(obj);
if (!GET_TC(tc)->itemValue) {
return 0;
Expand Down Expand Up @@ -1033,7 +1033,7 @@ static char *Index_iterGetName(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc,
static void Series_iterBegin(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
PyObjectEncoder *enc = (PyObjectEncoder *)tc->encoder;
GET_TC(tc)->index = 0;
GET_TC(tc)->cStr = PyObject_Malloc(20 * sizeof(char));
GET_TC(tc)->cStr = PyObject_Malloc(20);
enc->outputFormat = VALUES; // for contained series
if (!GET_TC(tc)->cStr) {
PyErr_NoMemory();
Expand All @@ -1048,13 +1048,13 @@ static int Series_iterNext(JSOBJ obj, JSONTypeContext *tc) {
const Py_ssize_t index = GET_TC(tc)->index;
Py_XDECREF(GET_TC(tc)->itemValue);
if (index == 0) {
memcpy(GET_TC(tc)->cStr, "name", sizeof(char) * 5);
memcpy(GET_TC(tc)->cStr, "name", 5);
GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "name");
} else if (index == 1) {
memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
memcpy(GET_TC(tc)->cStr, "index", 6);
GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
} else if (index == 2) {
memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
memcpy(GET_TC(tc)->cStr, "data", 5);
GET_TC(tc)->itemValue = get_values(obj);
if (!GET_TC(tc)->itemValue) {
return 0;
Expand Down Expand Up @@ -1088,7 +1088,7 @@ static char *Series_iterGetName(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc,
static void DataFrame_iterBegin(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
PyObjectEncoder *enc = (PyObjectEncoder *)tc->encoder;
GET_TC(tc)->index = 0;
GET_TC(tc)->cStr = PyObject_Malloc(20 * sizeof(char));
GET_TC(tc)->cStr = PyObject_Malloc(20);
enc->outputFormat = VALUES; // for contained series & index
if (!GET_TC(tc)->cStr) {
PyErr_NoMemory();
Expand All @@ -1103,13 +1103,13 @@ static int DataFrame_iterNext(JSOBJ obj, JSONTypeContext *tc) {
const Py_ssize_t index = GET_TC(tc)->index;
Py_XDECREF(GET_TC(tc)->itemValue);
if (index == 0) {
memcpy(GET_TC(tc)->cStr, "columns", sizeof(char) * 8);
memcpy(GET_TC(tc)->cStr, "columns", 8);
GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "columns");
} else if (index == 1) {
memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
memcpy(GET_TC(tc)->cStr, "index", 6);
GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
} else if (index == 2) {
memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
memcpy(GET_TC(tc)->cStr, "data", 5);
Py_INCREF(obj);
GET_TC(tc)->itemValue = obj;
} else {
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ cdef char* c_strftime(npy_datetimestruct *dts, char *fmt):
c_date.tm_yday = get_day_of_year(dts.year, dts.month, dts.day) - 1
c_date.tm_isdst = -1

result = <char*>malloc(result_len * sizeof(char))
result = <char*>malloc(result_len)
if result is NULL:
raise MemoryError()

Expand Down
Loading