Home | History | Annotate | Download | only in utils

Lines Matching full:nmemb

24 // Returns 0 in case of overflow of nmemb * size.
25 static int CheckSizeArgumentsOverflow(uint64_t nmemb, size_t size) {
26 const uint64_t total_size = nmemb * size;
27 if (nmemb == 0) return 1;
28 if ((uint64_t)size > WEBP_MAX_ALLOCABLE_MEMORY / nmemb) return 0;
33 void* WebPSafeMalloc(uint64_t nmemb, size_t size) {
34 if (!CheckSizeArgumentsOverflow(nmemb, size)) return NULL;
35 assert(nmemb * size > 0);
36 return malloc((size_t)(nmemb * size));
39 void* WebPSafeCalloc(uint64_t nmemb, size_t size) {
40 if (!CheckSizeArgumentsOverflow(nmemb, size)) return NULL;
41 assert(nmemb * size > 0);
42 return calloc((size_t)nmemb, size);