mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #26588: Optimize tracemalloc_realloc()
No need to remove the old trace if the memory block didn't move.
This commit is contained in:
parent
d65e0c7560
commit
42bcf37fcf
1 changed files with 6 additions and 1 deletions
|
@ -633,7 +633,12 @@ tracemalloc_realloc(void *ctx, void *ptr, size_t new_size)
|
||||||
/* an existing memory block has been resized */
|
/* an existing memory block has been resized */
|
||||||
|
|
||||||
TABLES_LOCK();
|
TABLES_LOCK();
|
||||||
REMOVE_TRACE(ptr);
|
|
||||||
|
/* tracemalloc_add_trace() updates the trace if there is already
|
||||||
|
a trace at address (domain, ptr2) */
|
||||||
|
if (ptr2 != ptr) {
|
||||||
|
REMOVE_TRACE(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
if (ADD_TRACE(ptr2, new_size) < 0) {
|
if (ADD_TRACE(ptr2, new_size) < 0) {
|
||||||
/* Memory allocation failed. The error cannot be reported to
|
/* Memory allocation failed. The error cannot be reported to
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue