summaryrefslogtreecommitdiffstats
path: root/modules/brotli/enc/memory.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-11-20 09:47:03 +0000
committerMoonchild <moonchild@palemoon.org>2020-11-20 09:47:03 +0000
commit5165ed02285315cc0bed7977c7bac6d0a90ca43c (patch)
tree9b761a21eb924915e51c2d803208e6c01b505a45 /modules/brotli/enc/memory.h
parente1db27e19989db11fef70f439cf95821316535b3 (diff)
parentca9abcdf1702c37bf00048dab3f460b2252873a3 (diff)
downloadUXP-RELBASE_20201120.tar
UXP-RELBASE_20201120.tar.gz
UXP-RELBASE_20201120.tar.lz
UXP-RELBASE_20201120.tar.xz
UXP-RELBASE_20201120.zip
Merge branch 'redwood' into releaseRELBASE_20201124RELBASE_20201120RC_20201120
Diffstat (limited to 'modules/brotli/enc/memory.h')
-rw-r--r--modules/brotli/enc/memory.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/modules/brotli/enc/memory.h b/modules/brotli/enc/memory.h
index ab928d019..832e7b2b6 100644
--- a/modules/brotli/enc/memory.h
+++ b/modules/brotli/enc/memory.h
@@ -56,6 +56,18 @@ BROTLI_INTERNAL void BrotliFree(MemoryManager* m, void* p);
#define BROTLI_IS_OOM(M) (!!(M)->is_oom)
#endif /* BROTLI_ENCODER_EXIT_ON_OOM */
+/*
+BROTLI_IS_NULL is a fake check, BROTLI_IS_OOM does the heavy lifting.
+The only purpose of it is to explain static analyzers the state of things.
+NB: use ONLY together with BROTLI_IS_OOM
+ AND ONLY for allocations in the current scope.
+ */
+#if defined(__clang_analyzer__) && !defined(BROTLI_ENCODER_EXIT_ON_OOM)
+#define BROTLI_IS_NULL(A) ((A) == nullptr)
+#else /* defined(__clang_analyzer__) */
+#define BROTLI_IS_NULL(A) (!!0)
+#endif /* defined(__clang_analyzer__) */
+
BROTLI_INTERNAL void BrotliWipeOutMemoryManager(MemoryManager* m);
/*
@@ -66,18 +78,18 @@ A: array
C: capacity
R: requested size
*/
-#define BROTLI_ENSURE_CAPACITY(M, T, A, C, R) { \
- if (C < (R)) { \
- size_t _new_size = (C == 0) ? (R) : C; \
- T* new_array; \
- while (_new_size < (R)) _new_size *= 2; \
- new_array = BROTLI_ALLOC((M), T, _new_size); \
- if (!BROTLI_IS_OOM(M) && C != 0) \
- memcpy(new_array, A, C * sizeof(T)); \
- BROTLI_FREE((M), A); \
- A = new_array; \
- C = _new_size; \
- } \
+#define BROTLI_ENSURE_CAPACITY(M, T, A, C, R) { \
+ if (C < (R)) { \
+ size_t _new_size = (C == 0) ? (R) : C; \
+ T* new_array; \
+ while (_new_size < (R)) _new_size *= 2; \
+ new_array = BROTLI_ALLOC((M), T, _new_size); \
+ if (!BROTLI_IS_OOM(M) && !BROTLI_IS_NULL(new_array) && C != 0) \
+ memcpy(new_array, A, C * sizeof(T)); \
+ BROTLI_FREE((M), A); \
+ A = new_array; \
+ C = _new_size; \
+ } \
}
/*