malloc-based string allocator is fixed, tested and working. Other cleanup
diff --git a/test/qcbor_decode_malloc_tests.c b/test/qcbor_decode_malloc_tests.c
new file mode 100644
index 0000000..91fff98
--- /dev/null
+++ b/test/qcbor_decode_malloc_tests.c
@@ -0,0 +1,103 @@
+//
+//  qcbor_decode_malloc_tests.c
+//  QCBOR
+//
+//  Created by Laurence Lundblade on 10/18/18.
+//  Copyright © 2018 Laurence Lundblade. All rights reserved.
+//
+
+#include "qcbor_decode_malloc_tests.h"
+#include "qcbor.h"
+#include <stdlib.h>
+
+
+/*
+ {"first integer": 42,
+ "an array of two strings": ["string1", "string2"],
+ "map in a map": {
+ "bytes 1": h'78787878',
+ "bytes 2": h'79797979',
+ "another int": 98, "text 2":
+ "lies, damn lies and statistics"}
+ }
+ */
+
+static uint8_t pValidMapEncoded[] = {
+    0xa3, 0x6d, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x18, 0x2a,
+    0x77, 0x61, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x77, 0x6f, 0x20,
+    0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x82, 0x67, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x31, 0x67,
+    0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x32, 0x6c, 0x6d, 0x61, 0x70, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20,
+    0x6d, 0x61, 0x70, 0xa4, 0x67, 0x62, 0x79, 0x74, 0x65, 0x73, 0x20, 0x31, 0x44, 0x78, 0x78, 0x78, 0x78,
+    0x67, 0x62, 0x79, 0x74, 0x65, 0x73, 0x20, 0x32, 0x44, 0x79, 0x79, 0x79, 0x79, 0x6b, 0x61, 0x6e, 0x6f,
+    0x74, 0x68, 0x65, 0x72, 0x20, 0x69, 0x6e, 0x74, 0x18, 0x62, 0x66, 0x74, 0x65, 0x78, 0x74, 0x20, 0x32,
+    0x78, 0x1e, 0x6c, 0x69, 0x65, 0x73, 0x2c, 0x20, 0x64, 0x61, 0x6d, 0x6e, 0x20, 0x6c, 0x69, 0x65, 0x73,
+    0x20, 0x61, 0x6e, 0x64, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73 } ;
+
+
+#define UNCONST_POINTER(ptr)    ((void *)(ptr))
+
+
+int MallocAllStringsTest()
+{
+    QCBORDecodeContext DC;
+    
+    // Next parse, save pointers to a few strings, destroy original and see all is OK.
+    MakeUsefulBufOnStack(CopyOfStorage, 160);
+    UsefulBufC CopyOf = UsefulBuf_Copy(CopyOfStorage, UsefulBuf_FromByteArrayLiteral(pValidMapEncoded));
+    
+    QCBORDecode_Init(&DC, CopyOf, QCBOR_DECODE_MODE_NORMAL);
+    QCBORStringAllocator *pAlloc = QCBORDecode_MakeMallocStringAllocator();
+    QCBORDecode_SetUpAllocator(&DC, pAlloc, true);
+
+
+    int nCBORError;
+    QCBORItem Item1, Item2, Item3, Item4;
+    if((nCBORError = QCBORDecode_GetNext(&DC, &Item1)))
+        return nCBORError;
+    if(Item1.uDataType != QCBOR_TYPE_MAP ||
+       Item1.val.uCount != 3)
+        return -1;
+    if((nCBORError = QCBORDecode_GetNext(&DC, &Item1)))
+        return nCBORError;
+    if((nCBORError = QCBORDecode_GetNext(&DC, &Item2)))
+        return nCBORError;
+    if((nCBORError = QCBORDecode_GetNext(&DC, &Item3)))
+        return nCBORError;
+    if((nCBORError = QCBORDecode_GetNext(&DC, &Item4)))
+        return nCBORError;
+    
+    UsefulBuf_Set(&CopyOfStorage, '_');
+    
+    if(Item1.uLabelType != QCBOR_TYPE_TEXT_STRING ||
+       Item1.label.string.len != 13 ||
+       Item1.uDataType != QCBOR_TYPE_INT64 ||
+       Item1.val.int64 != 42 ||
+       memcmp(Item1.label.string.ptr, "first integer", 13))
+        return -1;
+    
+    if(Item2.uLabelType != QCBOR_TYPE_TEXT_STRING ||
+       Item2.label.string.len != 23 ||
+       memcmp(Item2.label.string.ptr, "an array of two strings", 23) ||
+       Item2.uDataType != QCBOR_TYPE_ARRAY ||
+       Item2.val.uCount != 2)
+        return -1;
+    
+    if(Item3.uDataType != QCBOR_TYPE_TEXT_STRING ||
+       Item3.val.string.len != 7 ||
+       memcmp(Item3.val.string.ptr, "string1", 7))
+        return -1;
+    
+    if(Item4.uDataType != QCBOR_TYPE_TEXT_STRING ||
+       Item4.val.string.len != 7 ||
+       memcmp(Item4.val.string.ptr, "string2", 7))
+        return -1;
+    
+    (void)QCBORDecode_Finish(&DC);
+    
+    free(UNCONST_POINTER(Item1.label.string.ptr));
+    free(UNCONST_POINTER(Item2.label.string.ptr));
+    free(UNCONST_POINTER(Item3.val.string.ptr));
+    free(UNCONST_POINTER(Item4.val.string.ptr));
+
+    return 0;
+}
diff --git a/test/qcbor_decode_malloc_tests.h b/test/qcbor_decode_malloc_tests.h
new file mode 100644
index 0000000..685421c
--- /dev/null
+++ b/test/qcbor_decode_malloc_tests.h
@@ -0,0 +1,14 @@
+//
+//  qcbor_decode_malloc_tests.h
+//  QCBOR
+//
+//  Created by Laurence Lundblade on 10/18/18.
+//  Copyright © 2018 Laurence Lundblade. All rights reserved.
+//
+
+#ifndef qcbor_decode_malloc_tests_h
+#define qcbor_decode_malloc_tests_h
+
+int MallocAllStringsTest(void);
+
+#endif /* qcbor_decode_malloc_tests_h */
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index fce478d..bf48aa7 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -2257,9 +2257,6 @@
         return -1;
     }
     
-    
-    
-    
     return 0;
 }
 
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 3636ba4..8612341 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -775,7 +775,7 @@
    if(CheckResults(Enc, pExpectedEncodedInts))
      return -1;
    
-   if(Enc.len != sizeof(pExpectedEncodedInts) || bcmp(pEncoded, pExpectedEncodedInts, Enc.len))
+   if(Enc.len != sizeof(pExpectedEncodedInts) || memcmp(pEncoded, pExpectedEncodedInts, Enc.len))
       nReturn = -1;
    
    //printencoded(pEncoded, nEncodedLen);
@@ -817,7 +817,7 @@
       nReturn = -1;
    }
    
-   if(ECBOR.len != sizeof(pExpectedEncodedSimple) || bcmp(pEncoded, pExpectedEncodedSimple, ECBOR.len))
+   if(ECBOR.len != sizeof(pExpectedEncodedSimple) || memcmp(pEncoded, pExpectedEncodedSimple, ECBOR.len))
       nReturn = -1;
    
    // printencoded(pEncoded, nEncodedLen);
@@ -874,7 +874,7 @@
       nReturn = -1;
    }
    
-   if(nEncodedLen != sizeof(pExpectedEncodedDates) || bcmp(pEncoded, pExpectedEncodedDates, nEncodedLen))
+   if(nEncodedLen != sizeof(pExpectedEncodedDates) || memcmp(pEncoded, pExpectedEncodedDates, nEncodedLen))
       nReturn = -1;
    
    //printencoded(pEncoded, nEncodedLen);
diff --git a/test/run_tests.c b/test/run_tests.c
index 8a63d78..41c70e0 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -37,6 +37,7 @@
 #include "qcbor_decode_tests.h"
 #include "qcbor_encode_tests.h"
 #include "UsefulBuf_Tests.h"
+#include "qcbor_decode_malloc_tests.h"
 
 // Used to test the test runner
 int fail_test()
@@ -112,6 +113,7 @@
 
 
 test_entry s_tests[] = {
+    TEST_ENTRY(MallocAllStringsTest),
     TEST_ENTRY(AllocAllStringsTest),
     TEST_ENTRY(IndefiniteLengthNestTest),
     TEST_ENTRY(NestedMapTestIndefLen),