[gegl] gegl-scratch: remove NULL pointer guarantees
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl-scratch: remove NULL pointer guarantees
- Date: Fri, 11 Jan 2019 12:57:18 +0000 (UTC)
commit d98ea19777b6ccf78a6cc158212f13111fec5d93
Author: Ell <ell_se yahoo com>
Date: Fri Jan 11 07:41:38 2019 -0500
gegl-scratch: remove NULL pointer guarantees
In gegl-scratch, don't guarantee that allocating a 0-sized block
results in a NULL pointer, or that freeing a NULL pointer is valid.
It is still valid, however, to allocate 0-sized blocks, and to free
the returned pointers.
gegl/buffer/gegl-scratch.c | 9 ---------
gegl/buffer/gegl-scratch.h | 5 -----
2 files changed, 14 deletions(-)
---
diff --git a/gegl/buffer/gegl-scratch.c b/gegl/buffer/gegl-scratch.c
index 7b41324c2..b5bfc18e4 100644
--- a/gegl/buffer/gegl-scratch.c
+++ b/gegl/buffer/gegl-scratch.c
@@ -149,9 +149,6 @@ gegl_scratch_alloc (gsize size)
GeglScratchContext *context;
GeglScratchBlock *block;
- if (G_UNLIKELY (! size))
- return NULL;
-
if (G_UNLIKELY (size > GEGL_SCRATCH_MAX_BLOCK_SIZE))
{
block = gegl_scratch_block_new ((GeglScratchContext *) &void_context,
@@ -189,9 +186,6 @@ gegl_scratch_alloc0 (gsize size)
{
gpointer ptr;
- if (G_UNLIKELY (! size))
- return NULL;
-
ptr = gegl_scratch_alloc (size);
memset (ptr, 0, size);
@@ -205,9 +199,6 @@ gegl_scratch_free (gpointer ptr)
GeglScratchContext *context;
GeglScratchBlock *block;
- if (G_UNLIKELY (! ptr))
- return;
-
context = g_private_get (&gegl_scratch_context);
block = (GeglScratchBlock *) ((guint8 *) ptr -
GEGL_SCRATCH_BLOCK_DATA_OFFSET);
diff --git a/gegl/buffer/gegl-scratch.h b/gegl/buffer/gegl-scratch.h
index 21ba11cca..08e18366d 100644
--- a/gegl/buffer/gegl-scratch.h
+++ b/gegl/buffer/gegl-scratch.h
@@ -25,7 +25,6 @@
* @size: the number of bytes to allocte.
*
* Allocates @size bytes of scratch memory.
- * If @size is 0 it returns NULL.
*
* Returns a pointer to the allocated memory.
*/
@@ -36,7 +35,6 @@ gpointer gegl_scratch_alloc (gsize size) G_GNUC_MALLOC;
* @size: the number of bytes to allocte.
*
* Allocates @size bytes of scratch memory, initialized to zero.
- * If @size is 0 it returns NULL.
*
* Returns a pointer to the allocated memory.
*/
@@ -47,7 +45,6 @@ gpointer gegl_scratch_alloc0 (gsize size) G_GNUC_MALLOC;
* @ptr: the memory to free.
*
* Frees the memory pointed to by @ptr.
- * If @ptr is NULL, does nothing.
*
* The memory must have been allocated using one of the scratch-memory
* allocation functions.
@@ -65,7 +62,6 @@ void gegl_scratch_free (gpointer ptr);
*
* Allocates @n elements of type @type using scratch memory.
* The returned pointer is cast to a pointer to the given type.
- * If @n is 0 it returns %NULL.
* Care is taken to avoid overflow when calculating the size of
* the allocated block.
*
@@ -88,7 +84,6 @@ void gegl_scratch_free (gpointer ptr);
* Allocates @n elements of type @type using scratch memory,
* initialized to 0.
* The returned pointer is cast to a pointer to the given type.
- * If @n is 0 it returns %NULL.
* Care is taken to avoid overflow when calculating the size of
* the allocated block.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]