rename WebPDecBuffer::memory -> private_memory

This makes it clear that it shouldn't be used externally.

Change-Id: I10c04c6606abbe851b6a3b424832803e842b2057
This commit is contained in:
Pascal Massimino 2011-07-15 11:35:36 -07:00
parent fb5d659bbd
commit 9f01ce3afa
2 changed files with 13 additions and 11 deletions

View File

@ -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;
}
}
}

View File

@ -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