#ifdefined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN) #include <intrin.h> // This is a super stable value and setting it here avoids pulling in all of windows.h. #ifndef FAST_FAIL_FATAL_APP_EXIT #define FAST_FAIL_FATAL_APP_EXIT 7 #endif #endif
staticinlinevoid* throw_on_failure(size_t size, void* p) { if (size > 0 && p == nullptr) { // If we've got a nullptr here, the only reason we should have failed is running out of RAM.
sk_out_of_memory(size);
} return p;
}
void sk_free(void* p) { // The guard here produces a performance improvement across many tests, and many platforms. // Removing the check was tried in skia cl 588037. if (p != nullptr) {
free(p);
}
}
void* sk_malloc_flags(size_t size, unsigned flags) { void* p; if (flags & SK_MALLOC_ZERO_INITIALIZE) {
p = calloc(size, 1);
} else { #ifdefined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(__BIONIC__) /* TODO: After b/169449588 is fixed, we will want to change this to restore * original behavior instead of always disabling the flag. * TODO: After b/158870657 is fixed and scudo is used globally, we can assert when an * an error is returned.
*/ // malloc() generally doesn't initialize its memory and that's a huge security hole, // so Android has replaced its malloc() with one that zeros memory, // but that's a huge performance hit for HWUI, so turn it back off again.
(void)mallopt(M_THREAD_DISABLE_MEM_INIT, 1); #endif
p = malloc(size); #ifdefined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(__BIONIC__)
(void)mallopt(M_THREAD_DISABLE_MEM_INIT, 0); #endif
} if (flags & SK_MALLOC_THROW) { return throw_on_failure(size, p);
} else { return p;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.