- fixed some bugx when !LEAK_DETECTIVE
This commit is contained in:
@@ -342,9 +342,8 @@ chunk_t allocator_alloc_as_chunk(size_t bytes)
|
|||||||
{
|
{
|
||||||
chunk_t new_chunk;
|
chunk_t new_chunk;
|
||||||
new_chunk.ptr = malloc(bytes);
|
new_chunk.ptr = malloc(bytes);
|
||||||
if ((new_chunk.ptr == NULL)
|
if (new_chunk.ptr == NULL)
|
||||||
{
|
{
|
||||||
/* TODO log this case */
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
new_chunk.len = bytes;
|
new_chunk.len = bytes;
|
||||||
@@ -380,14 +379,14 @@ void * allocator_clone_bytes(void * pointer, size_t size)
|
|||||||
/**
|
/**
|
||||||
* Described in header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
static chunk_t clone_chunk(chunk_t chunk)
|
chunk_t allocator_clone_chunk(chunk_t chunk)
|
||||||
{
|
{
|
||||||
chunk_t clone = CHUNK_INITIALIZER;
|
chunk_t clone = CHUNK_INITIALIZER;
|
||||||
|
|
||||||
if (chunk.ptr && chunk.len > 0)
|
if (chunk.ptr && chunk.len > 0)
|
||||||
{
|
{
|
||||||
clone.ptr = malloc(chunk.len);
|
clone.ptr = malloc(chunk.len);
|
||||||
if (clone.ptr == NULL) {exit(-1)};
|
if (clone.ptr == NULL) {exit(-1);}
|
||||||
clone.len = chunk.len;
|
clone.len = chunk.len;
|
||||||
memcpy(clone.ptr, chunk.ptr, chunk.len);
|
memcpy(clone.ptr, chunk.ptr, chunk.len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,7 +300,7 @@
|
|||||||
*
|
*
|
||||||
* @ingroup utils
|
* @ingroup utils
|
||||||
*/
|
*/
|
||||||
chunk_t allocator_clone_bytes(chunk_t chunk);
|
chunk_t allocator_clone_chunk(chunk_t chunk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees memory used by chunk.
|
* Frees memory used by chunk.
|
||||||
|
|||||||
Reference in New Issue
Block a user