- fixed some bugx when !LEAK_DETECTIVE

This commit is contained in:
Martin Willi 2005-12-01 16:14:00 +00:00
parent 0675d5e1a1
commit bae00c63f7
2 changed files with 4 additions and 5 deletions

View File

@ -342,9 +342,8 @@ chunk_t allocator_alloc_as_chunk(size_t bytes)
{
chunk_t new_chunk;
new_chunk.ptr = malloc(bytes);
if ((new_chunk.ptr == NULL)
if (new_chunk.ptr == NULL)
{
/* TODO log this case */
exit(-1);
}
new_chunk.len = bytes;
@ -380,14 +379,14 @@ void * allocator_clone_bytes(void * pointer, size_t size)
/**
* Described in header
*/
static chunk_t clone_chunk(chunk_t chunk)
chunk_t allocator_clone_chunk(chunk_t chunk)
{
chunk_t clone = CHUNK_INITIALIZER;
if (chunk.ptr && chunk.len > 0)
{
clone.ptr = malloc(chunk.len);
if (clone.ptr == NULL) {exit(-1)};
if (clone.ptr == NULL) {exit(-1);}
clone.len = chunk.len;
memcpy(clone.ptr, chunk.ptr, chunk.len);
}

View File

@ -300,7 +300,7 @@
*
* @ingroup utils
*/
chunk_t allocator_clone_bytes(chunk_t chunk);
chunk_t allocator_clone_chunk(chunk_t chunk);
/**
* Frees memory used by chunk.