summaryrefslogtreecommitdiffstats
path: root/Modules/hashtable.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-23 08:25:01 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-03-23 08:25:01 (GMT)
commite8c6b2fd1bb75c6a3865745de30f26e235d3f12f (patch)
treea7687e057d730dfb732aaf145fad35025172a3cf /Modules/hashtable.c
parent42bcf37fcffa65592e401c43aa8c0190452b28b0 (diff)
downloadcpython-e8c6b2fd1bb75c6a3865745de30f26e235d3f12f.zip
cpython-e8c6b2fd1bb75c6a3865745de30f26e235d3f12f.tar.gz
cpython-e8c6b2fd1bb75c6a3865745de30f26e235d3f12f.tar.bz2
Issue #26588:
* _Py_HASHTABLE_ENTRY_DATA: change type from "char *" to "const void *" * Add _Py_HASHTABLE_ENTRY_WRITE_PKEY() macro * Rename _Py_HASHTABLE_ENTRY_WRITE_DATA() macro to _Py_HASHTABLE_ENTRY_WRITE_PDATA() * Add _Py_HASHTABLE_ENTRY_WRITE_DATA() macro
Diffstat (limited to 'Modules/hashtable.c')
-rw-r--r--Modules/hashtable.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/hashtable.c b/Modules/hashtable.c
index bb20cce..d80acc6 100644
--- a/Modules/hashtable.c
+++ b/Modules/hashtable.c
@@ -287,7 +287,7 @@ _Py_hashtable_pop_entry(_Py_hashtable_t *ht, size_t key_size, const void *pkey,
ht->entries--;
if (data != NULL)
- _Py_HASHTABLE_ENTRY_READ_DATA(ht, entry, data_size, data);
+ _Py_HASHTABLE_ENTRY_READ_PDATA(ht, entry, data_size, data);
ht->alloc.free(entry);
if ((float)ht->entries / (float)ht->num_buckets < HASHTABLE_LOW)
@@ -325,10 +325,8 @@ _Py_hashtable_set(_Py_hashtable_t *ht, size_t key_size, const void *pkey,
}
entry->key_hash = key_hash;
- memcpy((void *)_Py_HASHTABLE_ENTRY_KEY(entry), pkey, key_size);
-
- assert(data_size == ht->data_size);
- memcpy(_Py_HASHTABLE_ENTRY_DATA(ht, entry), data, data_size);
+ _Py_HASHTABLE_ENTRY_WRITE_PKEY(key_size, entry, pkey);
+ _Py_HASHTABLE_ENTRY_WRITE_PDATA(ht, entry, data_size, data);
_Py_slist_prepend(&ht->buckets[index], (_Py_slist_item_t*)entry);
ht->entries++;
@@ -350,7 +348,7 @@ _Py_hashtable_get(_Py_hashtable_t *ht, size_t key_size,const void *pkey,
entry = _Py_hashtable_get_entry(ht, key_size, pkey);
if (entry == NULL)
return 0;
- _Py_HASHTABLE_ENTRY_READ_DATA(ht, entry, data_size, data);
+ _Py_HASHTABLE_ENTRY_READ_PDATA(ht, entry, data_size, data);
return 1;
}