Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: third_party/libwebp/utils/utils.c

Issue 653803003: libwebp: update to 0.4.2-rc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libwebp/utils/quant_levels_dec.c ('k') | third_party/libwebp/webp/decode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 Google Inc. All Rights Reserved.
2 // 2 //
3 // Use of this source code is governed by a BSD-style license 3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the COPYING file in the root of the source 4 // that can be found in the COPYING file in the root of the source
5 // tree. An additional intellectual property rights grant can be found 5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may 6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree. 7 // be found in the AUTHORS file in the root of the source tree.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 // 9 //
10 // Misc. common utility functions 10 // Misc. common utility functions
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 #if defined(PRINT_MEM_TRAFFIC) 148 #if defined(PRINT_MEM_TRAFFIC)
149 fprintf(stderr, "Mem: %u (-%u)\n", 149 fprintf(stderr, "Mem: %u (-%u)\n",
150 (uint32_t)total_mem, (uint32_t)block->size_); 150 (uint32_t)total_mem, (uint32_t)block->size_);
151 #endif 151 #endif
152 free(block); 152 free(block);
153 } 153 }
154 } 154 }
155 } 155 }
156 156
157 #else 157 #else
158 #define Increment(v) do {} while(0) 158 #define Increment(v) do {} while (0)
159 #define AddMem(p, s) do {} while(0) 159 #define AddMem(p, s) do {} while (0)
160 #define SubMem(p) do {} while(0) 160 #define SubMem(p) do {} while (0)
161 #endif 161 #endif
162 162
163 // Returns 0 in case of overflow of nmemb * size. 163 // Returns 0 in case of overflow of nmemb * size.
164 static int CheckSizeArgumentsOverflow(uint64_t nmemb, size_t size) { 164 static int CheckSizeArgumentsOverflow(uint64_t nmemb, size_t size) {
165 const uint64_t total_size = nmemb * size; 165 const uint64_t total_size = nmemb * size;
166 if (nmemb == 0) return 1; 166 if (nmemb == 0) return 1;
167 if ((uint64_t)size > WEBP_MAX_ALLOCABLE_MEMORY / nmemb) return 0; 167 if ((uint64_t)size > WEBP_MAX_ALLOCABLE_MEMORY / nmemb) return 0;
168 if (total_size != (size_t)total_size) return 0; 168 if (total_size != (size_t)total_size) return 0;
169 #if defined(PRINT_MEM_INFO) && defined(MALLOC_FAIL_AT) 169 #if defined(PRINT_MEM_INFO) && defined(MALLOC_FAIL_AT)
170 if (countdown_to_fail > 0 && --countdown_to_fail == 0) { 170 if (countdown_to_fail > 0 && --countdown_to_fail == 0) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 void WebPSafeFree(void* const ptr) { 203 void WebPSafeFree(void* const ptr) {
204 if (ptr != NULL) { 204 if (ptr != NULL) {
205 Increment(&num_free_calls); 205 Increment(&num_free_calls);
206 SubMem(ptr); 206 SubMem(ptr);
207 } 207 }
208 free(ptr); 208 free(ptr);
209 } 209 }
210 210
211 //------------------------------------------------------------------------------ 211 //------------------------------------------------------------------------------
OLDNEW
« no previous file with comments | « third_party/libwebp/utils/quant_levels_dec.c ('k') | third_party/libwebp/webp/decode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698