make WebPEncodingSetError() take a const picture

This is a border-case situation: the picture is not const, because
we're change its error status. But taking it non-const forces
the caller to carry a non-const picture all around the code just
in case (0.00001% of the time?) something bad happen.
This pretty much the same as making all objects non-const because
we'll eventually call delete or free() on them, which is quite a
non-const operation. Well... Better allow constness enforcement for
the remaining 99.9999% of the code.

Change-Id: I9b93892a189a50feaec1a3a518ebf488eb6ff22f
This commit is contained in:
Pascal Massimino 2012-05-22 02:51:38 -07:00
parent 638528cd1e
commit fa8bc3dbca
2 changed files with 4 additions and 3 deletions

View File

@ -473,7 +473,7 @@ int VP8StatLoop(VP8Encoder* const enc);
// in webpenc.c // in webpenc.c
// Assign an error code to a picture. Return false for convenience. // Assign an error code to a picture. Return false for convenience.
int WebPEncodingSetError(WebPPicture* const pic, WebPEncodingError error); int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error);
int WebPReportProgress(VP8Encoder* const enc, int percent); int WebPReportProgress(VP8Encoder* const enc, int percent);
// in analysis.c // in analysis.c

View File

@ -306,10 +306,11 @@ static void StoreStats(VP8Encoder* const enc) {
WebPReportProgress(enc, 100); // done! WebPReportProgress(enc, 100); // done!
} }
int WebPEncodingSetError(WebPPicture* const pic, WebPEncodingError error) { int WebPEncodingSetError(const WebPPicture* const pic,
WebPEncodingError error) {
assert((int)error < VP8_ENC_ERROR_LAST); assert((int)error < VP8_ENC_ERROR_LAST);
assert((int)error >= VP8_ENC_OK); assert((int)error >= VP8_ENC_OK);
pic->error_code = error; ((WebPPicture*)pic)->error_code = error;
return 0; return 0;
} }