Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix unicode's struct encoding_map similarly.
  • Loading branch information
gpshead committed Mar 30, 2020
commit d3329fe0c707a615a8d01507a9d9d0c75b6481a4
6 changes: 3 additions & 3 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -8208,14 +8208,14 @@ struct encoding_map {
PyObject_HEAD
unsigned char level1[32];
int count2, count3;
unsigned char level23[1];
unsigned char level23[];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gpshead: Can you please write a PR which only contains this change? Since it doesn't touch the public C API, C++ compatibility is not an issue (I don't think that Python can be built with a C++ compiler). We can start with this change and see how it goes? See also the discussion at python/peps#1349

};

static PyObject*
encoding_map_size(PyObject *obj, PyObject* args)
{
struct encoding_map *map = (struct encoding_map*)obj;
return PyLong_FromLong(sizeof(*map) - 1 + 16*map->count2 +
return PyLong_FromLong(sizeof(*map) + 16*map->count2 +
128*map->count3);
}

Expand Down Expand Up @@ -8347,7 +8347,7 @@ PyUnicode_BuildEncodingMap(PyObject* string)

/* Create a three-level trie */
result = PyObject_MALLOC(sizeof(struct encoding_map) +
16*count2 + 128*count3 - 1);
16*count2 + 128*count3);
if (!result)
return PyErr_NoMemory();
PyObject_Init(result, &EncodingMapType);
Expand Down