This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch cpc_clean
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git

commit 5174316923ffc246a118228e95d58c8b53e150ad
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Mon Aug 19 11:59:21 2019 -0700

    consistent use of init flag
---
 cpc/src/fm85.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/cpc/src/fm85.cpp b/cpc/src/fm85.cpp
index e7544e4..1055fb1 100644
--- a/cpc/src/fm85.cpp
+++ b/cpc/src/fm85.cpp
@@ -61,20 +61,22 @@ void fm85Init (void) {
 // This is to support custom allocator and deallocator
 void fm85InitAD (void* (*alloc)(size_t), void (*dealloc)(void*)) {
   if (!fm85Initialized) {
-    fm85Initialized = 1;
     fm85alloc = alloc;
     fm85free = dealloc;
     fillByteLeadingZerosTable();
     fillByteTrailingZerosTable();
     makeTheDecodingTables();
-    fillInvPow2Tab ();
-    fillKxpByteLookup ();
+    fillInvPow2Tab();
+    fillKxpByteLookup();
+    fm85Initialized = 1;
   }
 }
 
 void fm85Clean (void) {
-  freeTheDecodingTables();
-  fm85Initialized = 0;
+  if (fm85Initialized) {
+    freeTheDecodingTables();
+    fm85Initialized = 0;
+  }
 }
 
 /*******************************************************/


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to