From 9f01ce3afaad30b7f398fa05890ed091803df536 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Fri, 15 Jul 2011 11:35:36 -0700 Subject: [PATCH] rename WebPDecBuffer::memory -> private_memory This makes it clear that it shouldn't be used externally. Change-Id: I10c04c6606abbe851b6a3b424832803e842b2057 --- src/dec/buffer.c | 16 ++++++++-------- src/webp/decode.h | 8 +++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/dec/buffer.c b/src/dec/buffer.c index ad868e57..c433d633 100644 --- a/src/dec/buffer.c +++ b/src/dec/buffer.c @@ -60,7 +60,7 @@ static VP8StatusCode AllocateBuffer(WebPDecBuffer* const buffer) { return VP8_STATUS_INVALID_PARAM; } - if (!buffer->is_external_memory && buffer->memory == NULL) { + if (!buffer->is_external_memory && buffer->private_memory == NULL) { uint8_t* output; WEBP_CSP_MODE mode = buffer->colorspace; int stride; @@ -87,7 +87,7 @@ static VP8StatusCode AllocateBuffer(WebPDecBuffer* const buffer) { return VP8_STATUS_INVALID_PARAM; } - buffer->memory = output = (uint8_t*)malloc((size_t)total_size); + buffer->private_memory = output = (uint8_t*)malloc((size_t)total_size); if (output == NULL) { return VP8_STATUS_OUT_OF_MEMORY; } @@ -164,8 +164,8 @@ int WebPInitDecBufferInternal(WebPDecBuffer* const buffer, int version) { void WebPFreeDecBuffer(WebPDecBuffer* const buffer) { if (buffer) { if (!buffer->is_external_memory) - free(buffer->memory); - buffer->memory = NULL; + free(buffer->private_memory); + buffer->private_memory = NULL; } } @@ -173,9 +173,9 @@ void WebPCopyDecBuffer(const WebPDecBuffer* const src, WebPDecBuffer* const dst) { if (src && dst) { *dst = *src; - if (src->memory) { + if (src->private_memory) { dst->is_external_memory = 1; // dst buffer doesn't own the memory. - dst->memory = NULL; + dst->private_memory = NULL; } } } @@ -184,9 +184,9 @@ void WebPCopyDecBuffer(const WebPDecBuffer* const src, void WebPGrabDecBuffer(WebPDecBuffer* const src, WebPDecBuffer* const dst) { if (src && dst) { *dst = *src; - if (src->memory) { + if (src->private_memory) { src->is_external_memory = 1; // src relinquishes ownership - src->memory = NULL; + src->private_memory = NULL; } } } diff --git a/src/webp/decode.h b/src/webp/decode.h index 195109ec..939cb964 100644 --- a/src/webp/decode.h +++ b/src/webp/decode.h @@ -139,12 +139,14 @@ typedef struct { // view as YUVA typedef struct { WEBP_CSP_MODE colorspace; // Colorspace. int width, height; // Dimensions. - int is_external_memory; // If true, the *memory pointer is not owned. + int is_external_memory; // If true, 'internal_memory' pointer is not used. union { WebPRGBABuffer RGBA; WebPYUVABuffer YUVA; - } u; // nameless union of buffer parameters. - uint8_t* memory; // main pointer (when is_external_memory is false) + } u; // Nameless union of buffer parameters. + uint8_t* private_memory; // Internally allocated memory (only when + // is_external_memory is false). Should not be used + // externally, but accessed via the buffer union. } WebPDecBuffer; // Internal, version-checked, entry point