summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-05-13 01:52:11 (GMT)
committerGitHub <noreply@github.com>2020-05-13 01:52:11 (GMT)
commitd95bd4214c2babe851b02562d973d60c02e639b7 (patch)
tree75f9961793fecd850e1b4455bb8a6383add6b9bf /Python
parent2d0a3d682f699cce8db6e30981d41d9125318726 (diff)
downloadcpython-d95bd4214c2babe851b02562d973d60c02e639b7.zip
cpython-d95bd4214c2babe851b02562d973d60c02e639b7.tar.gz
cpython-d95bd4214c2babe851b02562d973d60c02e639b7.tar.bz2
bpo-40609: _tracemalloc allocates traces (GH-20064)
Rewrite _tracemalloc to store "trace_t*" rather than directly "trace_t" in traces hash tables. Traces are now allocated on the heap memory, outside the hash table. Add tracemalloc_copy_traces() and tracemalloc_copy_domains() helper functions. Remove _Py_hashtable_copy() function since there is no API to copy a key or a value. Remove also _Py_hashtable_delete() function which was commented.
Diffstat (limited to 'Python')
-rw-r--r--Python/hashtable.c49
1 files changed, 0 insertions, 49 deletions
diff --git a/Python/hashtable.c b/Python/hashtable.c
index 0c013bb..e7681fb 100644
--- a/Python/hashtable.c
+++ b/Python/hashtable.c
@@ -350,21 +350,6 @@ _Py_hashtable_pop(_Py_hashtable_t *ht, const void *key,
}
-/* Code commented since the function is not needed in Python */
-#if 0
-void
-_Py_hashtable_delete(_Py_hashtable_t *ht, size_t const void *key)
-{
-#ifndef NDEBUG
- int found = _Py_hashtable_pop_entry(ht, key, NULL, 0);
- assert(found);
-#else
- (void)_Py_hashtable_pop_entry(ht, key, NULL, 0);
-#endif
-}
-#endif
-
-
int
_Py_hashtable_foreach(_Py_hashtable_t *ht,
_Py_hashtable_foreach_func func,
@@ -538,37 +523,3 @@ _Py_hashtable_destroy(_Py_hashtable_t *ht)
ht->alloc.free(ht->buckets);
ht->alloc.free(ht);
}
-
-
-_Py_hashtable_t *
-_Py_hashtable_copy(_Py_hashtable_t *src)
-{
- const size_t data_size = src->data_size;
- _Py_hashtable_t *dst;
- _Py_hashtable_entry_t *entry;
- size_t bucket;
- int err;
-
- dst = _Py_hashtable_new_full(data_size, src->num_buckets,
- src->hash_func,
- src->compare_func,
- src->key_destroy_func,
- src->value_destroy_func,
- &src->alloc);
- if (dst == NULL)
- return NULL;
-
- for (bucket=0; bucket < src->num_buckets; bucket++) {
- entry = TABLE_HEAD(src, bucket);
- for (; entry; entry = ENTRY_NEXT(entry)) {
- const void *key = entry->key;
- const void *pdata = _Py_HASHTABLE_ENTRY_PDATA(entry);
- err = _Py_hashtable_set(dst, key, data_size, pdata);
- if (err) {
- _Py_hashtable_destroy(dst);
- return NULL;
- }
- }
- }
- return dst;
-}