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
ref_indices -> hashtable.
  • Loading branch information
ericsnowcurrently committed Sep 16, 2021
commit 890b2f93dc1b02327b13a49355a3edd6e70a6885
20 changes: 10 additions & 10 deletions Python/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ typedef struct {
char *ptr;
const char *end;
char *buf;
_Py_hashtable_t *ref_indices;
_Py_hashtable_t *hashtable;
ssize_t refs_numobjects;
int version;
} WFILE;
Expand Down Expand Up @@ -298,14 +298,14 @@ w_ref(PyObject *v, char *flag, WFILE *p)
_Py_hashtable_entry_t *entry;
int w;

if (p->version < 3 || p->ref_indices == NULL)
if (p->version < 3 || p->hashtable == NULL)
return 0; /* not writing object references */

/* if it has only one reference, it definitely isn't shared */
if (Py_REFCNT(v) == 1)
return 0;

entry = _Py_hashtable_get_entry(p->ref_indices, v);
entry = _Py_hashtable_get_entry(p->hashtable, v);
if (entry != NULL) {
w = (int)(uintptr_t)entry->value;
if (p->refs_numobjects < 0) {
Expand Down Expand Up @@ -357,7 +357,7 @@ w_ref(PyObject *v, char *flag, WFILE *p)
p->refs_numobjects += 1;
}
Py_INCREF(v);
if (_Py_hashtable_set(p->ref_indices, v, (void *)(uintptr_t)w) < 0) {
if (_Py_hashtable_set(p->hashtable, v, (void *)(uintptr_t)w) < 0) {
Py_DECREF(v);
p->error = WFERR_UNMARSHALLABLE;
return 1;
Expand Down Expand Up @@ -627,10 +627,10 @@ static int
w_init_refs(WFILE *wf, int version)
{
if (version >= 3) {
wf->ref_indices = _Py_hashtable_new_full(_Py_hashtable_hash_ptr,
_Py_hashtable_compare_direct,
w_decref_entry, NULL, NULL);
if (wf->ref_indices == NULL) {
wf->hashtable = _Py_hashtable_new_full(_Py_hashtable_hash_ptr,
_Py_hashtable_compare_direct,
w_decref_entry, NULL, NULL);
if (wf->hashtable == NULL) {
PyErr_NoMemory();
return -1;
}
Expand All @@ -641,8 +641,8 @@ w_init_refs(WFILE *wf, int version)
static void
w_clear_refs(WFILE *wf)
{
if (wf->ref_indices != NULL) {
_Py_hashtable_destroy(wf->ref_indices);
if (wf->hashtable != NULL) {
_Py_hashtable_destroy(wf->hashtable);
}
}

Expand Down