Replace new/delete calls for Block* with malloc and free

Abierto
#890 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
backend

Línea de trabajo

The change sits in the MemPoolT template, which allocates and frees its Block* objects with new and delete; start by reading its block allocation and teardown code in tinyxml2.h. The reporter's workaround swaps in malloc and free, but the thread does not settle whether that is the right fix or whether the real problem is destruction order with a custom global allocator. Before editing, confirm that direction with a maintainer. Done means the pool's block lifetime is correct under overridden operator new and delete, with the existing tests still passing.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hello,

I am writing a program in which the new and delete operators are overloaded in order to use a custom allocator, and I found that the new and delete calls to allocate and deallocate memory for Block* in MemPoolT was causing several memory issues. I fixed these by replacing these with malloc() and free(). I'm not sure exactly why these issues were occurring.

EDIT: I believe this is because my allocator deconstructed the memory before the memory pool, meaning the memory pool was trying to deallocate memory that no longer exists

Lenguaje dominante
C++
Estrellas
5.8k
Forks
2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de leethomason/tinyxml2

Todos los issues de leethomason/tinyxml2

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.