diff --git a/CMakeLists.txt b/CMakeLists.txt index e72278fc..6604b20d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ set(FLEECE_BASE_SRC Fleece/Support/Backtrace.cc Fleece/Support/RefCounted.cc Fleece/Support/Writer.cc Fleece/Support/betterassert.cc - Fleece/Support/FLSlice.cc + Fleece/API_Impl/FLSlice.cc Fleece/Support/slice.cc Fleece/Support/varint.cc vendor/libb64/cdecode.c diff --git a/Fleece/API_Impl/FLSlice.cc b/Fleece/API_Impl/FLSlice.cc index 7a0efe68..35a94ec2 100644 --- a/Fleece/API_Impl/FLSlice.cc +++ b/Fleece/API_Impl/FLSlice.cc @@ -16,7 +16,10 @@ // limitations under the License. // -#include "FLSlice.h" +#include "fleece/FLSlice.h" +#include +#include +#include "betterassert.hh" bool FLSlice_Equal(FLSlice a, FLSlice b) { @@ -83,10 +86,6 @@ namespace fleece { free(self); } - static sharedBuffer* fromBuf(const void *buf) { - return offsetby((sharedBuffer*)buf, -((long long)offsetof(sharedBuffer, _buf))); - } - inline void retain() noexcept { assert(isHeapAligned(this)); ++_refCount; @@ -99,6 +98,10 @@ namespace fleece { } }; + static sharedBuffer* bufferFromBuf(const void *buf) { + return (sharedBuffer*)((uint8_t*)buf - offsetof(sharedBuffer, _buf)); + } + } using namespace fleece; @@ -137,13 +140,13 @@ void _FLBuf_Release(const void*); void _FLBuf_Retain(const void *buf) { if (buf) - sharedBuffer::fromBuf(buf)->retain(); + bufferFromBuf(buf)->retain(); } void _FLBuf_Release(const void *buf) { if (buf) - sharedBuffer::fromBuf(buf)->release(); + bufferFromBuf(buf)->release(); } diff --git a/Fleece/Support/Fleece.exp b/Fleece/Support/Fleece.exp index fb995a94..ee9cba74 100644 --- a/Fleece/Support/Fleece.exp +++ b/Fleece/Support/Fleece.exp @@ -8,8 +8,8 @@ _kFLEmptyDict _FLSlice_Equal _FLSlice_Compare -_FLSliceResult_Retain -_FLSliceResult_Release +__FLBuf_Retain +__FLBuf_Release _FLDoc_FromResultData _FLDoc_FromJSON diff --git a/Fleece/Support/betterassert.hh b/Fleece/Support/betterassert.hh index bb2d714b..90044df8 100644 --- a/Fleece/Support/betterassert.hh +++ b/Fleece/Support/betterassert.hh @@ -30,9 +30,9 @@ #endif // assert_always -#ifndef NDEBUG - - #undef assert +#undef assert +#ifdef NDEBUG + #define assert(e) ((void)0) +#else #define assert(e) assert_always(e) - #endif //NDEBUG diff --git a/cmake/platform_base.cmake b/cmake/platform_base.cmake index 847e68b8..68f1a550 100644 --- a/cmake/platform_base.cmake +++ b/cmake/platform_base.cmake @@ -8,6 +8,7 @@ function(set_source_files_base) set( ${BASE_SSS_RESULT} Fleece/API_Impl/Fleece.cc + Fleece/API_Impl/FLSlice.cc Fleece/Core/Array.cc Fleece/Core/DeepIterator.cc Fleece/Core/Dict.cc @@ -77,4 +78,4 @@ function(set_test_source_files_base) Experimental/KeyTree.cc PARENT_SCOPE ) -endfunction() \ No newline at end of file +endfunction()