summaryrefslogtreecommitdiffstats
path: root/Python/marshal.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-05-13 02:40:30 (GMT)
committerGitHub <noreply@github.com>2020-05-13 02:40:30 (GMT)
commit5b0a30354d8a8bb39a05ce10ca4f5c78b729f25b (patch)
tree82d3cb7f273b6af8b95d47546c56732258d19333 /Python/marshal.c
parentd95bd4214c2babe851b02562d973d60c02e639b7 (diff)
downloadcpython-5b0a30354d8a8bb39a05ce10ca4f5c78b729f25b.zip
cpython-5b0a30354d8a8bb39a05ce10ca4f5c78b729f25b.tar.gz
cpython-5b0a30354d8a8bb39a05ce10ca4f5c78b729f25b.tar.bz2
bpo-40609: _Py_hashtable_t values become void* (GH-20065)
_Py_hashtable_t values become regular "void *" pointers. * Add _Py_hashtable_entry_t.data member * Remove _Py_hashtable_t.data_size member * Remove _Py_hashtable_t.get_func member. It is no longer needed to specialize _Py_hashtable_get() for a specific value size, since all entries now have the same size (void*). * Remove the following macros: * _Py_HASHTABLE_GET() * _Py_HASHTABLE_SET() * _Py_HASHTABLE_SET_NODATA() * _Py_HASHTABLE_POP() * Rename _Py_hashtable_pop() to _Py_hashtable_steal() * _Py_hashtable_foreach() callback now gets key and value rather than entry. * Remove _Py_hashtable_value_destroy_func type. value_destroy_func callback now only has a single parameter: data (void*).
Diffstat (limited to 'Python/marshal.c')
-rw-r--r--Python/marshal.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index 7c99c1e..b096ff8 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -302,10 +302,10 @@ w_ref(PyObject *v, char *flag, WFILE *p)
if (Py_REFCNT(v) == 1)
return 0;
- entry = _Py_HASHTABLE_GET_ENTRY(p->hashtable, v);
+ entry = _Py_hashtable_get_entry(p->hashtable, v);
if (entry != NULL) {
/* write the reference index to the stream */
- _Py_HASHTABLE_ENTRY_READ_DATA(p->hashtable, entry, w);
+ w = (int)(uintptr_t)entry->value;
/* we don't store "long" indices in the dict */
assert(0 <= w && w <= 0x7fffffff);
w_byte(TYPE_REF, p);
@@ -320,7 +320,7 @@ w_ref(PyObject *v, char *flag, WFILE *p)
}
w = (int)s;
Py_INCREF(v);
- if (_Py_HASHTABLE_SET(p->hashtable, v, w) < 0) {
+ if (_Py_hashtable_set(p->hashtable, v, (void *)(uintptr_t)w) < 0) {
Py_DECREF(v);
goto err;
}
@@ -556,8 +556,7 @@ static int
w_init_refs(WFILE *wf, int version)
{
if (version >= 3) {
- wf->hashtable = _Py_hashtable_new_full(sizeof(int), 0,
- _Py_hashtable_hash_ptr,
+ wf->hashtable = _Py_hashtable_new_full(_Py_hashtable_hash_ptr,
_Py_hashtable_compare_direct,
w_decref_entry, NULL, NULL);
if (wf->hashtable == NULL) {