From b83205a538f420fd78220519540503616cf636cd Mon Sep 17 00:00:00 2001 From: smcgruer Date: Mon, 16 Mar 2015 14:45:00 -0700 Subject: [PATCH] Fix build for UCLIBC platforms malloc_usable_size does not exist in UCLIBC, so fall back to just returning 0 for SkVarAlloc::heap_size(). BUG=skia: Review URL: https://codereview.chromium.org/1006073003 --- src/core/SkVarAlloc.cpp | 4 ++-- tests/VarAllocTest.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp index ba5d6f5..88bd170 100644 --- a/src/core/SkVarAlloc.cpp +++ b/src/core/SkVarAlloc.cpp @@ -47,7 +47,7 @@ void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) { #if defined(SK_BUILD_FOR_MAC) SkASSERT(alloc == malloc_good_size(alloc)); -#elif defined(SK_BUILD_FOR_UNIX) +#elif defined(SK_BUILD_FOR_UNIX) && !defined(__UCLIBC__) // TODO(mtklein): tune so we can assert something like this //SkASSERT(alloc == malloc_usable_size(fBlock)); #endif @@ -56,7 +56,7 @@ void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) { static size_t heap_size(void* p) { #if defined(SK_BUILD_FOR_MAC) return malloc_size(p); -#elif defined(SK_BUILD_FOR_UNIX) +#elif defined(SK_BUILD_FOR_UNIX) && !defined(__UCLIBC__) return malloc_usable_size(p); #elif defined(SK_BUILD_FOR_WIN32) return _msize(p); diff --git a/tests/VarAllocTest.cpp b/tests/VarAllocTest.cpp index 18e4214..b1a0cb3 100644 --- a/tests/VarAllocTest.cpp +++ b/tests/VarAllocTest.cpp @@ -6,8 +6,8 @@ DEF_TEST(VarAlloc, r) { char* p = va.alloc(128, SK_MALLOC_THROW); sk_bzero(p, 128); // Just checking this is safe. -#ifndef SK_BUILD_FOR_ANDROID - // This method will always return 0 on Android. +#if !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) + // This method will always return 0 on Android and UCLIBC platforms. REPORTER_ASSERT(r, va.approxBytesAllocated() >= 128); #endif } -- 2.7.4