gmio_core: force size to 0 for NULL buffer

This commit is contained in:
Hugues Delorme 2015-03-30 16:48:05 +02:00
parent 8c92dc2e76
commit ca43839585
2 changed files with 5 additions and 2 deletions

View File

@ -35,7 +35,7 @@ gmio_buffer_t gmio_buffer(void* ptr, size_t size)
{
gmio_buffer_t buff;
buff.ptr = ptr;
buff.size = size;
buff.size = ptr != NULL ? size : 0;
buff.deallocate_func = NULL;
return buff;
}

View File

@ -40,7 +40,10 @@ typedef struct gmio_buffer gmio_buffer_t;
GMIO_C_LINKAGE_BEGIN
/*! Returns an initialized gmio_buffer object */
/*! Returns an initialized gmio_buffer object
*
* If \p ptr is NULL then gmio_buffer::size is forced to \c 0
*/
GMIO_LIB_EXPORT gmio_buffer_t gmio_buffer(void* ptr, size_t size);
/*! Returns a gmio_buffer object allocated with standard malloc() */