Commit 42bcf37f authored by Victor Stinner's avatar Victor Stinner

Issue #26588: Optimize tracemalloc_realloc()

No need to remove the old trace if the memory block didn't move.
parent d65e0c75
......@@ -633,7 +633,12 @@ tracemalloc_realloc(void *ctx, void *ptr, size_t new_size)
/* an existing memory block has been resized */
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) {
/* Memory allocation failed. The error cannot be reported to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment