Moved oic_string and combined mallocs to central place
authorErich Keane <erich.keane@intel.com>
Tue, 2 Jun 2015 00:15:24 +0000 (17:15 -0700)
committerErich Keane <erich.keane@intel.com>
Wed, 3 Jun 2015 21:14:53 +0000 (21:14 +0000)
Created the c_common directory to contain all stuff common
to the C stack.  Currently, oic_string has been added.  Additionally,
ocmalloc and oic_malloc have been combined and moved to this directory.

Future targets will be the ocrandom and oc/oic_logger libraries.

Change-Id: Ic4858881565367b3e69b47d6b0e0145a42d4ace0
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1163
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Doug Hudson <douglas.hudson@intel.com>
35 files changed:
resource/SConscript
resource/c_common/SConscript [new file with mode: 0644]
resource/c_common/oic_malloc/include/oic_malloc.h [moved from resource/csdk/connectivity/common/inc/oic_malloc.h with 100% similarity]
resource/c_common/oic_malloc/src/oic_malloc.c [moved from resource/csdk/connectivity/common/src/oic_malloc.c with 100% similarity]
resource/c_common/oic_malloc/test/SConscript [new file with mode: 0644]
resource/c_common/oic_malloc/test/linux/oic_malloc_tests.cpp [moved from resource/csdk/ocmalloc/test/linux/unittest.cpp with 69% similarity]
resource/c_common/oic_string/include/oic_string.h [moved from resource/csdk/connectivity/common/inc/oic_string.h with 100% similarity]
resource/c_common/oic_string/src/oic_string.c [moved from resource/csdk/connectivity/common/src/oic_string.c with 99% similarity]
resource/c_common/oic_string/test/SConscript [new file with mode: 0644]
resource/c_common/oic_string/test/linux/oic_string_tests.cpp [moved from resource/csdk/connectivity/test/oic_string_tests.cpp with 100% similarity]
resource/csdk/SConscript
resource/csdk/connectivity/common/SConscript
resource/csdk/connectivity/test/SConscript
resource/csdk/doc/Doxyfile
resource/csdk/ocmalloc/include/ocmalloc.h [deleted file]
resource/csdk/ocmalloc/src/ocmalloc.c [deleted file]
resource/csdk/ocmalloc/test/linux/README [deleted file]
resource/csdk/ocrandom/test/SConscript
resource/csdk/security/src/ocsecurity.c
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserverslow.cpp
resource/csdk/stack/src/occlientcb.c
resource/csdk/stack/src/occollection.c
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/src/oicgroup.c
resource/csdk/stack/test/SConscript
resource/csdk/stack/test/stacktests.cpp
resource/docs/devdocs.doxyfile
resource/src/InProcServerWrapper.cpp
resource/src/SConscript
resource/unit_tests.scons

index 95a2468..d86a982 100644 (file)
@@ -36,6 +36,9 @@ if target_os not in ['arduino', 'darwin', 'ios', 'android']:
 # Build libcoap
 SConscript('csdk/connectivity/lib/libcoap-4.1.1/SConscript')
 
+# Build C Common dependencies
+SConscript('c_common/SConscript')
+
 # Build connectivity
 SConscript('csdk/connectivity/SConscript')
 
diff --git a/resource/c_common/SConscript b/resource/c_common/SConscript
new file mode 100644 (file)
index 0000000..ff0513b
--- /dev/null
@@ -0,0 +1,47 @@
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+
+Import('env')
+import os
+
+env.AppendUnique(CPPPATH = [
+            os.path.join(Dir('.').abspath, 'oic_malloc/include'),
+            os.path.join(Dir('.').abspath, 'oic_string/include')
+        ])
+env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common')])
+env.AppendUnique(LIBS = ['c_common'])
+
+common_env = env.Clone()
+
+######################################################################
+# Build flags
+######################################################################
+
+######################################################################
+# Source files and Targets
+######################################################################
+common_src = [
+    'oic_string/src/oic_string.c',
+    'oic_malloc/src/oic_malloc.c'
+    ]
+
+commonlib = common_env.StaticLibrary('c_common', common_src)
+common_env.InstallTarget(commonlib, 'c_common')
diff --git a/resource/c_common/oic_malloc/test/SConscript b/resource/c_common/oic_malloc/test/SConscript
new file mode 100644 (file)
index 0000000..0443928
--- /dev/null
@@ -0,0 +1,61 @@
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+Import('env')
+import os
+
+malloctest_env = env.Clone()
+src_dir = malloctest_env.get('SRC_DIR')
+
+######################################################################
+# Build flags
+######################################################################
+malloctest_env.PrependUnique(CPPPATH = [
+        '../include',
+               '../../../../extlibs/gtest/gtest-1.7.0/include'
+        ])
+
+malloctest_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common')])
+malloctest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
+malloctest_env.PrependUnique(LIBS = ['c_common', 'gtest', 'gtest_main', 'pthread'])
+
+if env.get('LOGGING'):
+       malloctest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+#
+######################################################################
+# Source files and Targets
+######################################################################
+malloctests = malloctest_env.Program('malloctests', ['linux/oic_malloc_tests.cpp'])
+
+Alias("test", [malloctests])
+
+env.AppendTarget('test')
+if env.get('TEST') == '1':
+       target_os = env.get('TARGET_OS')
+       if target_os == 'linux':
+               out_dir = env.get('BUILD_DIR')
+               result_dir = env.get('BUILD_DIR') + '/test_out/'
+               if not os.path.isdir(result_dir):
+                       os.makedirs(result_dir)
+               malloctest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
+               malloctest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
+               malloctest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
+               ut = malloctest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_ccommon_malloc_test.memcheck ' + out_dir + 'resource/c_common/oic_malloc/test/malloctests')
+               AlwaysBuild ('ut')
@@ -20,7 +20,7 @@
 
 
 extern "C" {
-    #include "ocmalloc.h"
+    #include "oic_malloc.h"
 }
 
 #include "gtest/gtest.h"
@@ -51,90 +51,90 @@ static uint8_t *pBuffer;
 //  Tests
 //-----------------------------------------------------------------------------
 
-TEST(OCMalloc, MallocPass1)
+TEST(OICMalloc, MallocPass1)
 {
     // Try to allocate a small buffer
-    pBuffer = (uint8_t *)OCMalloc(1);
+    pBuffer = (uint8_t *)OICMalloc(1);
     EXPECT_TRUE(pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCMalloc, MallocPass2)
+TEST(OICMalloc, MallocPass2)
 {
     // Try to allocate a small buffer
-    pBuffer = (uint8_t *)OCMalloc(128);
+    pBuffer = (uint8_t *)OICMalloc(128);
     EXPECT_TRUE(pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCMalloc, MallocFail1)
+TEST(OICMalloc, MallocFail1)
 {
     // Try to allocate a buffer of size 0
-    pBuffer = (uint8_t *)OCMalloc(0);
+    pBuffer = (uint8_t *)OICMalloc(0);
     EXPECT_TRUE(NULL == pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCMalloc, MallocFail2)
+TEST(OICMalloc, MallocFail2)
 {
     // Try to allocate a ridiculous amount of RAM
-    pBuffer = (uint8_t *)OCMalloc((size_t)0x7FFFFFFFFFFFFFFF);
+    pBuffer = (uint8_t *)OICMalloc((size_t)0x7FFFFFFFFFFFFFFF);
     EXPECT_TRUE(NULL == pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCCalloc, CallocPass1)
+TEST(OICCalloc, CallocPass1)
 {
     // Try to allocate a small buffer
-    pBuffer = (uint8_t *)OCCalloc(1, 1);
+    pBuffer = (uint8_t *)OICCalloc(1, 1);
     EXPECT_TRUE(pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCCalloc, CallocPass2)
+TEST(OICCalloc, CallocPass2)
 {
     // Try to allocate a small buffer
-    pBuffer = (uint8_t *)OCCalloc(1, 128);
+    pBuffer = (uint8_t *)OICCalloc(1, 128);
     EXPECT_TRUE(pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCCalloc, CallocPass3)
+TEST(OICCalloc, CallocPass3)
 {
     // Try to allocate a buffer for an array
-    pBuffer = (uint8_t *)OCCalloc(5, 128);
+    pBuffer = (uint8_t *)OICCalloc(5, 128);
     EXPECT_TRUE(pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCCalloc, CallocFail1)
+TEST(OICCalloc, CallocFail1)
 {
     // Try to allocate a buffer of size 0
-    pBuffer = (uint8_t *)OCCalloc(1, 0);
+    pBuffer = (uint8_t *)OICCalloc(1, 0);
     EXPECT_TRUE(NULL == pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCCalloc, CallocFail2)
+TEST(OICCalloc, CallocFail2)
 {
     // Try to allocate a buffer with num of 0
-    pBuffer = (uint8_t *)OCCalloc(0, 5);
+    pBuffer = (uint8_t *)OICCalloc(0, 5);
     EXPECT_TRUE(NULL == pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCCalloc, CallocFail3)
+TEST(OICCalloc, CallocFail3)
 {
     // Try to allocate a buffer with size and num 0
-    pBuffer = (uint8_t *)OCCalloc(0, 0);
+    pBuffer = (uint8_t *)OICCalloc(0, 0);
     EXPECT_TRUE(NULL == pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
 
-TEST(OCCalloc, CallocFail4)
+TEST(OICCalloc, CallocFail4)
 {
     // Try to allocate a ridiculous amount of RAM
-    pBuffer = (uint8_t *)OCCalloc(1, (size_t)0x7FFFFFFFFFFFFFFF);
+    pBuffer = (uint8_t *)OICCalloc(1, (size_t)0x7FFFFFFFFFFFFFFF);
     EXPECT_TRUE(NULL == pBuffer);
-    OCFree(pBuffer);
+    OICFree(pBuffer);
 }
@@ -21,7 +21,6 @@
 
 #include <string.h>
 #include <assert.h>
-#include "logger.h"
 #include "oic_malloc.h"
 
 #define TAG "OIC_STRING"
diff --git a/resource/c_common/oic_string/test/SConscript b/resource/c_common/oic_string/test/SConscript
new file mode 100644 (file)
index 0000000..9aacebc
--- /dev/null
@@ -0,0 +1,61 @@
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+Import('env')
+import os
+
+stringtest_env = env.Clone()
+src_dir = stringtest_env.get('SRC_DIR')
+
+######################################################################
+# Build flags
+######################################################################
+stringtest_env.PrependUnique(CPPPATH = [
+        '../include',
+               '../../../../extlibs/gtest/gtest-1.7.0/include'
+        ])
+
+stringtest_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common')])
+stringtest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
+stringtest_env.PrependUnique(LIBS = ['c_common', 'gtest', 'gtest_main', 'pthread'])
+
+if env.get('LOGGING'):
+       stringtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+#
+######################################################################
+# Source files and Targets
+######################################################################
+stringtests = stringtest_env.Program('stringtests', ['linux/oic_string_tests.cpp'])
+
+Alias("test", [stringtests])
+
+env.AppendTarget('test')
+if env.get('TEST') == '1':
+       target_os = env.get('TARGET_OS')
+       if target_os == 'linux':
+               out_dir = env.get('BUILD_DIR')
+               result_dir = env.get('BUILD_DIR') + '/test_out/'
+               if not os.path.isdir(result_dir):
+                       os.makedirs(result_dir)
+               stringtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
+               stringtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
+               stringtest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
+               ut = stringtest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_ccommon_string_test.memcheck ' + out_dir + 'resource/c_common/oic_string/test/stringtests')
+               AlwaysBuild ('ut')
index 63e6462..a357e85 100644 (file)
@@ -43,7 +43,6 @@ liboctbstack_env.PrependUnique(CPPPATH = [
                '../../extlibs/timer/',
                'logger/include',
                'ocrandom/include',
-               'ocmalloc/include',
                'stack/include',
                'stack/include/internal',
                '../oc_logger/include',
@@ -90,6 +89,8 @@ if env.get('SECURED') == '1':
 if env.get('LOGGING'):
        liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
+liboctbstack_env.Append(LIBS = ['c_common'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
@@ -106,9 +107,9 @@ liboctbstack_src = [
        OCTBSTACK_SRC + 'oicgroup.c',
        'security/src/ocsecurity.c',
        'logger/src/logger.c',
-       'ocrandom/src/ocrandom.c',
-       'ocmalloc/src/ocmalloc.c'
+       'ocrandom/src/ocrandom.c'
        ]
+
 if target_os in ['arduino','darwin','ios'] :
        static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
        liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
index 7c6c558..bc75711 100644 (file)
@@ -27,8 +27,6 @@ for item in temp:
 # Source files and Target(s)
 ######################################################################
 ca_common_src = [
-               ca_common_src_path + 'oic_malloc.c',
-               ca_common_src_path + 'oic_string.c',
                ca_common_src_path + 'uarraylist.c',
                ca_common_src_path + 'uqueue.c',
        ]
index ca464db..24f2bdc 100644 (file)
@@ -32,7 +32,6 @@ catest_env.PrependUnique(CPPPATH = [
                 '../../ocsocket/include',
                 '../../logger/include',
                 '../../stack/include',
-                '../../ocmalloc/include',
                 '../../extlibs/cjson',
                 '../../../oc_logger/include',
                 '../../../../extlibs/gtest/gtest-1.7.0/include'
@@ -74,8 +73,8 @@ if env.get('LOGGING'):
 catests = catest_env.Program('catests', ['catests.cpp',
                                          'caprotocolmessagetest.cpp',
                                                'ca_api_unittest.cpp',
-                                               'camutex_tests.cpp',
-                                               'oic_string_tests.cpp'])
+                                               'camutex_tests.cpp'
+                                               ])
 
 Alias("test", [catests])
 
index ca2ba59..a95101f 100644 (file)
@@ -32,7 +32,7 @@ PROJECT_NAME           = "IoTivity C SDK"
 # This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER         = 
+PROJECT_NUMBER         =
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer
@@ -662,7 +662,6 @@ WARN_LOGFILE           =
 INPUT                  = . \
                                                 ../stack/include \
                                                 ../ocsocket/include \
-                                                ../ocmalloc/include \
                                                 ../ocrandom/include \
                                                 ../occoap/include \
 
diff --git a/resource/csdk/ocmalloc/include/ocmalloc.h b/resource/csdk/ocmalloc/include/ocmalloc.h
deleted file mode 100644 (file)
index 7019982..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef OCMALLOC_H_
-#define OCMALLOC_H_
-
-// The purpose of this module is to allow custom dynamic memory allocation
-// code to easily be added to the TB Stack by redefining the OCMalloc and
-// OCFree functions.  Examples of when this might be needed are on TB
-// platforms that do not support dynamic allocation or if a memory pool
-// needs to be added.
-//
-// Note that these functions are intended to be used ONLY within the TB
-// stack and NOT by the application code.  The application should be
-// responsible for its own dynamic allocation.
-
-//-----------------------------------------------------------------------------
-// Includes
-//-----------------------------------------------------------------------------
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-//-----------------------------------------------------------------------------
-// Defines
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// Typedefs
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// Function prototypes
-//-----------------------------------------------------------------------------
-
-/**
- * Allocates a block of size bytes, returning a pointer to the beginning of
- * the allocated block.
- *
- * @param size - Size of the memory block in bytes, where size > 0
- *
- * @return
- *     on success, a pointer to the allocated memory block
- *     on failure, a null pointer is returned
- */
-void *OCMalloc(size_t size);
-
-/**
- * Allocates a block of memory for an array of num elements, each of them
- * size bytes long and initializes all its bits to zero.
- *
- * @param num - The number of elements
- * @param size - Size of the element type in bytes, where size > 0
- *
- * @return
- *     on success, a pointer to the allocated memory block
- *     on failure, a null pointer is returned
- */
-void *OCCalloc(size_t num, size_t size);
-
-/**
- * Deallocate a block of memory previously allocated by a call to OCMalloc
- *
- * @param ptr - Pointer to block of memory previously allocated by OCMalloc.
- *              If ptr is a null pointer, the function does nothing.
- */
-void OCFree(void *ptr);
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif /* OCMALLOC_H_ */
diff --git a/resource/csdk/ocmalloc/src/ocmalloc.c b/resource/csdk/ocmalloc/src/ocmalloc.c
deleted file mode 100644 (file)
index fe62c15..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-
-//-----------------------------------------------------------------------------
-// Includes
-//-----------------------------------------------------------------------------
-#include <stdlib.h>
-#include "ocmalloc.h"
-
-// Enable extra debug logging for malloc.  Comment out to disable
-//#define ENABLE_MALLOC_DEBUG  (1)
-
-#ifdef ENABLE_MALLOC_DEBUG
-    #include "logger.h"
-    #define TAG PCF("OCMalloc")
-#endif
-
-//-----------------------------------------------------------------------------
-// Typedefs
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Private variables
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Macros
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Internal API function
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// Private internal function prototypes
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// Public APIs
-//-----------------------------------------------------------------------------
-
-void *OCMalloc(size_t size)
-{
-    if (0 == size)
-    {
-        return NULL;
-    }
-
-#ifdef ENABLE_MALLOC_DEBUG
-    void *ptr = 0;
-
-    ptr = malloc(size);
-    OC_LOG_V(INFO, TAG, "malloc: ptr=%p, size=%u", ptr, size);
-    return ptr;
-#else
-    return malloc(size);
-#endif
-}
-
-void *OCCalloc(size_t num, size_t size)
-{
-    if(0 == size || 0 == num)
-    {
-        return NULL;
-    }
-
-#ifdef ENABLE_MALLOC_DEBUG
-    void *ptr = 0;
-
-    ptr = calloc(num, size);
-    OC_LOG_V(INFO, TAG, "calloc: ptr=%p, num=%u, size=%u", ptr, num, size);
-    return ptr;
-#else
-    return calloc(num, size);
-#endif
-}
-
-void OCFree(void *ptr)
-{
-#ifdef ENABLE_MALLOC_DEBUG
-    OC_LOG_V(INFO, TAG, "free: ptr=%p", ptr);
-#endif
-
-    free(ptr);
-}
-
diff --git a/resource/csdk/ocmalloc/test/linux/README b/resource/csdk/ocmalloc/test/linux/README
deleted file mode 100644 (file)
index 72e3c1c..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
--------------------------------------------------------------------------------
-  NOTICE - Transition to SCONS
--------------------------------------------------------------------------------
-
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
-directory. The build steps used in continuous integration can be found
-in auto_build.sh which is also in the the repository root directory.
-
--------------------------------------------------------------------------------
-
-# To build the ocmalloc google unit test for Linux:
-
-# First
-cd <root>/csdk
-make deepclean
-
-make BUILD=release
-# or
-make BUILD=debug
-
-# Next
-cd <root>/csdk/ocmalloc/test/linux
-
-make BUILD=release
-# or
-make BUILD=debug
-
-# Run the test test
-
-<root>/csdk/ocmalloc/test/linux/release/unittest
-# or
-<root>/csdk/ocmalloc/test/linux/debug/unittest
index ab221cd..eeb858a 100644 (file)
@@ -31,7 +31,6 @@ src_dir = randomtest_env.get('SRC_DIR')
 randomtest_env.PrependUnique(CPPPATH = [
         '../include',
                '../../logger/include',
-               '../../ocmalloc/include',
                '../../../oc_logger/include',
                '../../../../extlibs/gtest/gtest-1.7.0/include'
                ])
index 3dfe6e0..27e5b79 100644 (file)
@@ -19,7 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "ocstack.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 #include "ocsecurity.h"
 #include "ocsecurityconfig.h"
 #include "cainterface.h"
@@ -42,7 +42,7 @@ void DeinitOCSecurityInfo()
         // Initialize sensitive data to zeroes before freeing.
         memset(secConfigData, 0, secConfigDataLen);
 
-        OCFree(secConfigData);
+        OICFree(secConfigData);
         secConfigData = NULL;
     }
 }
@@ -52,7 +52,7 @@ void DeinitOCSecurityInfo()
  * retrieve PSK credentials from RI security layer.
  *
  * Note: When finished, caller should initialize memory to zeroes and
- * invoke OCFree to delete @p credInfo.
+ * invoke OICFree to delete @p credInfo.
  *
  * @param credInfo
  *     binary blob containing PSK credentials
@@ -73,7 +73,7 @@ void GetDtlsPskCredentials(CADtlsPskCredsBlob_t **credInfo)
         {
             if (osb->type == OC_BLOB_TYPE_PSK)
             {
-                caBlob = (CADtlsPskCredsBlob_t *)OCCalloc(sizeof(CADtlsPskCredsBlob_t), 1);
+                caBlob = (CADtlsPskCredsBlob_t *)OICCalloc(sizeof(CADtlsPskCredsBlob_t), 1);
                 if (caBlob)
                 {
                     OCDtlsPskCredsBlob * ocBlob = (OCDtlsPskCredsBlob *)osb->val;
@@ -81,7 +81,7 @@ void GetDtlsPskCredentials(CADtlsPskCredsBlob_t **credInfo)
                     memcpy(caBlob->identity, ocBlob->identity, sizeof(caBlob->identity));
                     caBlob->num = ocBlob->num;
                     caBlob->creds =
-                        (OCDtlsPskCreds*) OCMalloc(caBlob->num * sizeof(OCDtlsPskCreds));
+                        (OCDtlsPskCreds*) OICMalloc(caBlob->num * sizeof(OCDtlsPskCreds));
                     if (caBlob->creds)
                     {
                         memcpy(caBlob->creds, ocBlob->creds,
@@ -101,8 +101,8 @@ void GetDtlsPskCredentials(CADtlsPskCredsBlob_t **credInfo)
     // Clear memory if any memory allocation failed above
     if(caBlob)
     {
-        OCFree(caBlob->creds);
-        OCFree(caBlob);
+        OICFree(caBlob->creds);
+        OICFree(caBlob);
     }
 }
 #endif //__WITH_DTLS__
@@ -219,7 +219,7 @@ OCStackResult OCSecSetConfigData(const OCSecConfigData *cfgData,
         // Remove existing blob
         DeinitOCSecurityInfo();
         // Allocate storage for new blob
-        secConfigData = (OCSecConfigData*)OCMalloc(len);
+        secConfigData = (OCSecConfigData*)OICMalloc(len);
         if (secConfigData)
         {
             memcpy(secConfigData, cfgData, len);
index b3250b7..ab43795 100644 (file)
@@ -27,7 +27,6 @@ samples_env = env.Clone()
 samples_env.PrependUnique(CPPPATH = [
                '../../../../logger/include',
                '../../../../stack/include',
-               '../../../../ocmalloc/include',
                '../../../../../../extlibs/cjson',
                '../../../../../oc_logger/include',
                '../../../../../connectivity/lib/libcoap-4.1.1'
index 828f76e..e2f6a61 100644 (file)
@@ -29,7 +29,7 @@
 #include "logger.h"
 #include "occlientbasicops.h"
 #include "cJSON.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 
 #define MAX_IP_ADDR_ST_SZ  16 //string size of "155.255.255.255" (15 + 1)
 #define MAX_PORT_ST_SZ  6     //string size of "65535" (5 + 1)
@@ -397,7 +397,7 @@ const char * getIPAddr(const OCClientResponse * clientResponse)
     }
 
     char * ipaddr = NULL;
-    if((ipaddr = (char *) OCCalloc(1, MAX_IP_ADDR_ST_SZ)))
+    if((ipaddr = (char *) OICCalloc(1, MAX_IP_ADDR_ST_SZ)))
     {
         snprintf(ipaddr, MAX_IP_ADDR_ST_SZ, "%d.%d.%d.%d", a,b,c,d);
     }
@@ -417,7 +417,7 @@ const char * getPort(const OCClientResponse * clientResponse)
     }
 
     char * port = NULL;
-    if((port = (char *) OCCalloc(1, MAX_PORT_ST_SZ)))
+    if((port = (char *) OICCalloc(1, MAX_PORT_ST_SZ)))
     {
         snprintf(port, MAX_PORT_ST_SZ, "%d", p);
     }
@@ -463,7 +463,7 @@ int parseJSON(const char * resJSONPayload, char ** sid_c,
         if (cJSON_GetObjectItem(resource, "sid"))
         {
             char * sid = cJSON_GetObjectItem(resource, "sid")->valuestring;
-            if((* sid_c = (char *)OCCalloc(1, strlen (sid) + 1)))
+            if((* sid_c = (char *)OICCalloc(1, strlen (sid) + 1)))
             {
                 memcpy(* sid_c, sid, strlen(sid) + 1);
             }
@@ -479,7 +479,7 @@ int parseJSON(const char * resJSONPayload, char ** sid_c,
             return OC_STACK_INVALID_JSON;
         }
 
-        if(!(* uri_c =  (char ** )OCMalloc ((* totalRes) * sizeof(char **))))
+        if(!(* uri_c =  (char ** )OICMalloc ((* totalRes) * sizeof(char **))))
         {
             OC_LOG(ERROR, TAG, "Memory not allocated to sid_c array");
             return OC_STACK_NO_MEMORY;
@@ -492,7 +492,7 @@ int parseJSON(const char * resJSONPayload, char ** sid_c,
             if (cJSON_GetObjectItem(resource, "href"))
             {
                 char *uri= cJSON_GetObjectItem(resource, "href")->valuestring;
-                if(((*uri_c)[i] = (char *)OCCalloc(1, strlen (uri) + 1)))
+                if(((*uri_c)[i] = (char *)OICCalloc(1, strlen (uri) + 1)))
                 {
                     memcpy((*uri_c)[i], uri, strlen(uri) + 1);
                 }
@@ -556,8 +556,8 @@ void collectUniqueResource(const OCClientResponse * clientResponse)
             != OC_STACK_OK)
     {
         OC_LOG(ERROR, TAG, "Error while parsing JSON payload in OCClientResponse");
-        OCFree(sid);
-        OCFree(uri);
+        OICFree(sid);
+        OICFree(uri);
         return;
     }
 
@@ -576,8 +576,8 @@ void collectUniqueResource(const OCClientResponse * clientResponse)
         }
     }
 
-    OCFree(sid);
-    OCFree(uri);
+    OICFree(sid);
+    OICFree(uri);
  }
 
 /* This function searches for the resource(sid:uri) in the ResourceList.
@@ -603,7 +603,7 @@ int insertResource(const char * sid, char const * uri,
     }
 
     //Creating new ResourceNode
-    if((iter = (ResourceNode *) OCMalloc(sizeof(ResourceNode))))
+    if((iter = (ResourceNode *) OICMalloc(sizeof(ResourceNode))))
     {
         iter->sid = sid;
         iter->uri = uri;
@@ -678,11 +678,11 @@ void freeResourceList()
     {
         temp = resourceList;
         resourceList = resourceList->next;
-        OCFree((void *)temp->sid);
-        OCFree((void *)temp->uri);
-        OCFree((void *)temp->ip);
-        OCFree((void *)temp->port);
-        OCFree(temp);
+        OICFree((void *)temp->sid);
+        OICFree((void *)temp->uri);
+        OICFree((void *)temp->ip);
+        OICFree((void *)temp->port);
+        OICFree(temp);
     }
 }
 
index eb015e4..305844c 100644 (file)
@@ -27,7 +27,7 @@
 #include <sys/time.h>
 #include <list>
 #include "ocstack.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 #include "logger.h"
 #include "cJSON.h"
 #include "ocserverslow.h"
@@ -155,20 +155,20 @@ OCEntityHandlerRequest *CopyRequest(OCEntityHandlerRequest *entityHandlerRequest
 {
     OC_LOG(INFO, TAG, "Copying received request for slow response");
     OCEntityHandlerRequest *request =
-            (OCEntityHandlerRequest *)OCMalloc(sizeof(OCEntityHandlerRequest));
+            (OCEntityHandlerRequest *)OICMalloc(sizeof(OCEntityHandlerRequest));
     if (request)
     {
         // Do shallow copy
         memcpy(request, entityHandlerRequest, sizeof(OCEntityHandlerRequest));
         // Do deep copy of query
         request->query =
-                (char * )OCMalloc(strlen((const char *)entityHandlerRequest->query) + 1);
+                (char * )OICMalloc(strlen((const char *)entityHandlerRequest->query) + 1);
         if (request->query)
         {
             strcpy((char *)request->query, (const char *)entityHandlerRequest->query);
 
             // Copy the request payload
-            request->reqJSONPayload = (char * )OCMalloc(
+            request->reqJSONPayload = (char * )OICMalloc(
                             strlen((const char *)entityHandlerRequest->reqJSONPayload) + 1);
             if (request->reqJSONPayload)
             {
@@ -181,14 +181,14 @@ OCEntityHandlerRequest *CopyRequest(OCEntityHandlerRequest *entityHandlerRequest
             }
             else
             {
-                OCFree(request->query);
-                OCFree(request);
+                OICFree(request->query);
+                OICFree(request);
                 request = NULL;
             }
         }
         else
         {
-            OCFree(request);
+            OICFree(request);
             request = NULL;
         }
     }
@@ -285,9 +285,9 @@ void AlarmHandler(int sig)
                     entityHandlerRequest->method);
         }
         // Free the request
-        OCFree(entityHandlerRequest->query);
-        OCFree(entityHandlerRequest->reqJSONPayload);
-        OCFree(entityHandlerRequest);
+        OICFree(entityHandlerRequest->query);
+        OICFree(entityHandlerRequest->reqJSONPayload);
+        OICFree(entityHandlerRequest);
 
         // If there are more requests in list, re-arm the alarm signal
         if (gRequestList.empty())
@@ -337,9 +337,9 @@ int main(int argc, char* argv[])
     {
         for (auto iter = gRequestList.begin(); iter != gRequestList.end(); ++iter)
         {
-            OCFree((*iter)->query);
-            OCFree((*iter)->reqJSONPayload);
-            OCFree(*iter);
+            OICFree((*iter)->query);
+            OICFree((*iter)->reqJSONPayload);
+            OICFree(*iter);
         }
         gRequestList.clear();
     }
index c2b324f..39022c1 100644 (file)
@@ -22,7 +22,7 @@
 #include "occlientcb.h"
 #include "utlist.h"
 #include "logger.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 #include <string.h>
 
 #ifdef WITH_ARDUINO
@@ -63,7 +63,7 @@ AddClientCB (ClientCB** clientCB, OCCallbackData* cbData,
 
     if(!cbNode)// If it does not already exist, create new node.
     {
-        cbNode = (ClientCB*) OCMalloc(sizeof(ClientCB));
+        cbNode = (ClientCB*) OICMalloc(sizeof(ClientCB));
         if(!cbNode)
         {
             *clientCB = NULL;
@@ -113,9 +113,9 @@ AddClientCB (ClientCB** clientCB, OCCallbackData* cbData,
             cbData->cd(cbData->context);
         }
 
-        OCFree(token);
-        OCFree(*handle);
-        OCFree(requestUri);
+        OICFree(token);
+        OICFree(*handle);
+        OICFree(requestUri);
         *handle = cbNode->handle;
     }
 
@@ -127,10 +127,10 @@ AddClientCB (ClientCB** clientCB, OCCallbackData* cbData,
     }
     else
     {
-        OCFree(resourceTypeName);
+        OICFree(resourceTypeName);
     }
     #else
-    OCFree(resourceTypeName);
+    OICFree(resourceTypeName);
     #endif
 
     return OC_STACK_OK;
@@ -147,8 +147,8 @@ void DeleteClientCB(ClientCB * cbNode)
         OC_LOG(INFO, TAG, PCF("deleting tokens"));
         OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)cbNode->token, cbNode->tokenLength);
         CADestroyToken (cbNode->token);
-        OCFree(cbNode->handle);
-        OCFree(cbNode->requestUri);
+        OICFree(cbNode->handle);
+        OICFree(cbNode->requestUri);
         if(cbNode->deleteCallback)
         {
             cbNode->deleteCallback(cbNode->context);
@@ -157,8 +157,8 @@ void DeleteClientCB(ClientCB * cbNode)
         #ifdef WITH_PRESENCE
         if(cbNode->presence)
         {
-            OCFree(cbNode->presence->timeOut);
-            OCFree(cbNode->presence);
+            OICFree(cbNode->presence->timeOut);
+            OICFree(cbNode->presence);
         }
         if(cbNode->method == OC_REST_PRESENCE)
         {
@@ -167,13 +167,13 @@ void DeleteClientCB(ClientCB * cbNode)
             while(pointer)
             {
                 next = pointer->next;
-                OCFree(pointer->resourcetypename);
-                OCFree(pointer);
+                OICFree(pointer->resourcetypename);
+                OICFree(pointer);
                 pointer = next;
             }
         }
         #endif // WITH_PRESENCE
-        OCFree(cbNode);
+        OICFree(cbNode);
         cbNode = NULL;
     }
 }
@@ -259,7 +259,7 @@ OCStackResult InsertResourceTypeFilter(ClientCB * cbNode, char * resourceTypeNam
     if(cbNode && resourceTypeName)
     {
         // Form a new resourceType member.
-        newResourceType = (OCResourceType *) OCMalloc(sizeof(OCResourceType));
+        newResourceType = (OCResourceType *) OICMalloc(sizeof(OCResourceType));
         if(!newResourceType)
         {
             return OC_STACK_NO_MEMORY;
@@ -311,7 +311,7 @@ OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, char* uri, uint32_t n
 
     OCMulticastNode *node;
 
-    node = (OCMulticastNode*) OCMalloc(sizeof(OCMulticastNode));
+    node = (OCMulticastNode*) OICMalloc(sizeof(OCMulticastNode));
 
     if (node)
     {
index 108c302..174eb64 100644 (file)
@@ -31,9 +31,8 @@
 #include "ocstackinternal.h"
 #include "ocresourcehandler.h"
 #include "logger.h"
-#include "ocmalloc.h"
 #include "cJSON.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 
 /// Module Name
 #include <stdio.h>
@@ -261,7 +260,7 @@ static OCStackResult BuildRootResourceJSON(OCResource *resource,
     }
 
     cJSON_Delete (resObj);
-    OCFree(jsonStr);
+    OICFree(jsonStr);
 
     return ret;
 }
index bb7f4a8..a341629 100644 (file)
@@ -25,7 +25,7 @@
 #include "ocobserve.h"
 #include "ocresourcehandler.h"
 #include "ocrandom.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 #include "ocserverrequest.h"
 #include "cJSON.h"
 
@@ -102,7 +102,7 @@ static OCStackResult BuildPresenceResponse(char *out, uint16_t *remaining,
             ret = OC_STACK_ERROR;
         }
 
-        OCFree(jsonStr);
+        OICFree(jsonStr);
     }
     else
     {
@@ -332,7 +332,7 @@ OCStackResult SendListObserverNotification (OCResource * resource,
                     {
                         OCEntityHandlerResponse ehResponse = {};
                         ehResponse.ehResult = OC_EH_OK;
-                        ehResponse.payload = (char *) OCMalloc(MAX_RESPONSE_LENGTH + 1);
+                        ehResponse.payload = (char *) OICMalloc(MAX_RESPONSE_LENGTH + 1);
                         if(!ehResponse.payload)
                         {
                             FindAndDeleteServerRequest(request);
@@ -352,7 +352,7 @@ OCStackResult SendListObserverNotification (OCResource * resource,
                             // Increment only if OCDoResponse is successful
                             numSentNotification++;
 
-                            OCFree(ehResponse.payload);
+                            OICFree(ehResponse.payload);
                             FindAndDeleteServerRequest(request);
                         }
                         else
@@ -439,19 +439,19 @@ OCStackResult AddObserver (const char         *resUri,
         return OC_STACK_INVALID_PARAM;
     }
 
-    obsNode = (ResourceObserver *) OCCalloc(1, sizeof(ResourceObserver));
+    obsNode = (ResourceObserver *) OICCalloc(1, sizeof(ResourceObserver));
     if (obsNode)
     {
         obsNode->observeId = obsId;
 
-        obsNode->resUri = (char *)OCMalloc(strlen(resUri)+1);
+        obsNode->resUri = (char *)OICMalloc(strlen(resUri)+1);
         VERIFY_NON_NULL (obsNode->resUri);
         memcpy (obsNode->resUri, resUri, strlen(resUri)+1);
 
         obsNode->qos = qos;
         if(query)
         {
-            obsNode->query = (char *)OCMalloc(strlen(query)+1);
+            obsNode->query = (char *)OICMalloc(strlen(query)+1);
             VERIFY_NON_NULL (obsNode->query);
             memcpy (obsNode->query, query, strlen(query)+1);
         }
@@ -459,7 +459,7 @@ OCStackResult AddObserver (const char         *resUri,
         // particular library implementation (it may or may not be a null pointer).
         if(tokenLength)
         {
-            obsNode->token = (CAToken_t)OCMalloc(tokenLength);
+            obsNode->token = (CAToken_t)OICMalloc(tokenLength);
             VERIFY_NON_NULL (obsNode->token);
             memcpy(obsNode->token, token, tokenLength);
         }
@@ -474,9 +474,9 @@ OCStackResult AddObserver (const char         *resUri,
 exit:
     if (obsNode)
     {
-        OCFree(obsNode->resUri);
-        OCFree(obsNode->query);
-        OCFree(obsNode);
+        OICFree(obsNode->resUri);
+        OICFree(obsNode->query);
+        OICFree(obsNode);
     }
     return OC_STACK_NO_MEMORY;
 }
@@ -535,10 +535,10 @@ OCStackResult DeleteObserverUsingToken (CAToken_t token, uint8_t tokenLength)
         OC_LOG_V(INFO, TAG, PCF("deleting tokens"));
         OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)obsNode->token, tokenLength);
         LL_DELETE (serverObsList, obsNode);
-        OCFree(obsNode->resUri);
-        OCFree(obsNode->query);
-        OCFree(obsNode->token);
-        OCFree(obsNode);
+        OICFree(obsNode->resUri);
+        OICFree(obsNode->query);
+        OICFree(obsNode->token);
+        OICFree(obsNode);
     }
     // it is ok if we did not find the observer...
     return OC_STACK_OK;
@@ -579,7 +579,7 @@ CreateObserveHeaderOption (CAHeaderOption_t **caHdrOpt,
 
     CAHeaderOption_t *tmpHdrOpt = NULL;
 
-    tmpHdrOpt = (CAHeaderOption_t *) OCCalloc ((numOptions+1), sizeof(CAHeaderOption_t));
+    tmpHdrOpt = (CAHeaderOption_t *) OICCalloc ((numOptions+1), sizeof(CAHeaderOption_t));
     if (NULL == tmpHdrOpt)
     {
         return OC_STACK_NO_MEMORY;
index 435bb9f..2b1b4e9 100644 (file)
@@ -30,7 +30,7 @@
 #include "ocresourcehandler.h"
 #include "ocobserve.h"
 #include "occollection.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 #include "logger.h"
 #include "cJSON.h"
 
@@ -98,7 +98,7 @@ static OCStackResult GetSecurePortInfo(CATransportType_t connType, uint16_t *por
         }
     }
 
-    OCFree(info);
+    OICFree(info);
     return ret;
 }
 
@@ -424,7 +424,7 @@ BuildVirtualResourceResponse(const OCResource *resourcePtr, uint8_t filterOn,
         ret = OC_STACK_ERROR;
     }
     cJSON_Delete (resObj);
-    OCFree (jsonStr);
+    OICFree (jsonStr);
 
     OC_LOG(INFO, TAG, PCF("Exiting BuildVirtualResourceResponse"));
     return ret;
@@ -459,7 +459,7 @@ OCStackResult BuildVirtualResourceResponseForDevice(uint8_t filterOn, char *filt
             ret = OC_STACK_ERROR;
         }
 
-        OCFree(jsonStr);
+        OICFree(jsonStr);
     }
     else
     {
@@ -490,7 +490,7 @@ OCStackResult BuildVirtualResourceResponseForPlatform(char *out, uint16_t *remai
             OC_LOG_V(ERROR, TAG, PCF("Platform info string too big. len: %u"), jsonLen);
             ret = OC_STACK_ERROR;
         }
-        OCFree(jsonStr);
+        OICFree(jsonStr);
     }
     else
     {
@@ -1057,37 +1057,37 @@ void DeletePlatformInfo()
 {
     OC_LOG(INFO, TAG, PCF("Deleting platform info."));
 
-    OCFree(savedPlatformInfo.platformID);
+    OICFree(savedPlatformInfo.platformID);
     savedPlatformInfo.platformID = NULL;
 
-    OCFree(savedPlatformInfo.manufacturerName);
+    OICFree(savedPlatformInfo.manufacturerName);
     savedPlatformInfo.manufacturerName = NULL;
 
-    OCFree(savedPlatformInfo.manufacturerUrl);
+    OICFree(savedPlatformInfo.manufacturerUrl);
     savedPlatformInfo.manufacturerUrl = NULL;
 
-    OCFree(savedPlatformInfo.modelNumber);
+    OICFree(savedPlatformInfo.modelNumber);
     savedPlatformInfo.modelNumber = NULL;
 
-    OCFree(savedPlatformInfo.dateOfManufacture);
+    OICFree(savedPlatformInfo.dateOfManufacture);
     savedPlatformInfo.dateOfManufacture = NULL;
 
-    OCFree(savedPlatformInfo.platformVersion);
+    OICFree(savedPlatformInfo.platformVersion);
     savedPlatformInfo.platformVersion = NULL;
 
-    OCFree(savedPlatformInfo.operatingSystemVersion);
+    OICFree(savedPlatformInfo.operatingSystemVersion);
     savedPlatformInfo.operatingSystemVersion = NULL;
 
-    OCFree(savedPlatformInfo.hardwareVersion);
+    OICFree(savedPlatformInfo.hardwareVersion);
     savedPlatformInfo.hardwareVersion = NULL;
 
-    OCFree(savedPlatformInfo.firmwareVersion);
+    OICFree(savedPlatformInfo.firmwareVersion);
     savedPlatformInfo.firmwareVersion = NULL;
 
-    OCFree(savedPlatformInfo.supportUrl);
+    OICFree(savedPlatformInfo.supportUrl);
     savedPlatformInfo.supportUrl = NULL;
 
-    OCFree(savedPlatformInfo.systemTime);
+    OICFree(savedPlatformInfo.systemTime);
     savedPlatformInfo.systemTime = NULL;
 }
 
@@ -1157,7 +1157,7 @@ void DeleteDeviceInfo()
 {
     OC_LOG(INFO, TAG, PCF("Deleting device info."));
 
-    OCFree(savedDeviceInfo.deviceName);
+    OICFree(savedDeviceInfo.deviceName);
     savedDeviceInfo.deviceName = NULL;
 }
 
index 8448b87..d0a018f 100644 (file)
@@ -22,7 +22,7 @@
 #include "ocstack.h"
 #include "ocserverrequest.h"
 #include "ocresourcehandler.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 
 #include "cacommon.h"
 #include "cainterface.h"
@@ -55,10 +55,10 @@ static OCStackResult AddServerResponse (OCServerResponse ** response, OCRequestH
 {
     OCServerResponse * serverResponse = NULL;
 
-    serverResponse = (OCServerResponse *) OCCalloc(1, sizeof(OCServerResponse));
+    serverResponse = (OCServerResponse *) OICCalloc(1, sizeof(OCServerResponse));
     VERIFY_NON_NULL(serverResponse);
 
-    serverResponse->payload = (char *) OCCalloc(1, MAX_RESPONSE_LENGTH);
+    serverResponse->payload = (char *) OICCalloc(1, MAX_RESPONSE_LENGTH);
     VERIFY_NON_NULL(serverResponse->payload);
 
     serverResponse->remainingPayloadSize = MAX_RESPONSE_LENGTH;
@@ -72,7 +72,7 @@ static OCStackResult AddServerResponse (OCServerResponse ** response, OCRequestH
 exit:
     if (serverResponse)
     {
-        OCFree(serverResponse);
+        OICFree(serverResponse);
         serverResponse = NULL;
     }
     *response = NULL;
@@ -89,8 +89,8 @@ static void DeleteServerRequest(OCServerRequest * serverRequest)
     if(serverRequest)
     {
         LL_DELETE(serverRequestList, serverRequest);
-        OCFree(serverRequest->requestToken);
-        OCFree(serverRequest);
+        OICFree(serverRequest->requestToken);
+        OICFree(serverRequest);
         serverRequest = NULL;
         OC_LOG(INFO, TAG, PCF("Server Request Removed!!"));
     }
@@ -106,8 +106,8 @@ static void DeleteServerResponse(OCServerResponse * serverResponse)
     if(serverResponse)
     {
         LL_DELETE(serverResponseList, serverResponse);
-        OCFree(serverResponse->payload);
-        OCFree(serverResponse);
+        OICFree(serverResponse->payload);
+        OICFree(serverResponse);
         OC_LOG(INFO, TAG, PCF("Server Response Removed!!"));
     }
 }
@@ -252,7 +252,7 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
     //Note: OCServerRequest includes 1 byte for the JSON Payload.  payloadSize is calculated
     //as the required length of the string, so this will result in enough room for the
     //null terminator as well.
-    serverRequest = (OCServerRequest *) OCCalloc(1, sizeof(OCServerRequest) +
+    serverRequest = (OCServerRequest *) OICCalloc(1, sizeof(OCServerRequest) +
         (reqTotalSize ? reqTotalSize : 1) - 1);
     VERIFY_NON_NULL(serverRequest);
 
@@ -294,7 +294,7 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
         // particular library implementation (it may or may not be a null pointer).
         if (tokenLength)
         {
-            serverRequest->requestToken = (CAToken_t) OCMalloc(tokenLength);
+            serverRequest->requestToken = (CAToken_t) OICMalloc(tokenLength);
             VERIFY_NON_NULL(serverRequest->requestToken);
             memcpy(serverRequest->requestToken, requestToken, tokenLength);
         }
@@ -322,7 +322,7 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
 exit:
     if (serverRequest)
     {
-        OCFree(serverRequest);
+        OICFree(serverRequest);
         serverRequest = NULL;
     }
     *request = NULL;
@@ -497,7 +497,7 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
     }
 
     responseInfo.info.messageId = serverRequest->coapID;
-    responseInfo.info.token = (CAToken_t)OCMalloc(CA_MAX_TOKEN_LEN+1);
+    responseInfo.info.token = (CAToken_t)OICMalloc(CA_MAX_TOKEN_LEN+1);
     if (!responseInfo.info.token)
     {
         OC_LOG(FATAL, TAG, "Response Info Token is NULL");
@@ -519,13 +519,13 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
     if(responseInfo.info.numOptions > 0)
     {
         responseInfo.info.options = (CAHeaderOption_t *)
-                                      OCCalloc(responseInfo.info.numOptions,
+                                      OICCalloc(responseInfo.info.numOptions,
                                               sizeof(CAHeaderOption_t));
 
         if(!responseInfo.info.options)
         {
             OC_LOG(FATAL, TAG, PCF("options is NULL"));
-            OCFree(responseInfo.info.token);
+            OICFree(responseInfo.info.token);
             return OC_STACK_NO_MEMORY;
         }
 
@@ -607,8 +607,8 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
     }
     #endif
 
-    OCFree(responseInfo.info.token);
-    OCFree(responseInfo.info.options);
+    OICFree(responseInfo.info.token);
+    OICFree(responseInfo.info.options);
     //Delete the request
     FindAndDeleteServerRequest(serverRequest);
     return result;
index 8206bb6..73dacb9 100644 (file)
@@ -39,7 +39,7 @@
 #include "occlientcb.h"
 #include "ocobserve.h"
 #include "ocrandom.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 #include "ocserverrequest.h"
 #include "ocsecurityinternal.h"
 
@@ -117,7 +117,7 @@ OCDeviceEntityHandler defaultDeviceHandler;
 #define MILLISECONDS_PER_SECOND   (1000)
 /**
  * Parse the presence payload and extract various parameters.
- * Note: Caller should invoke OCFree after done with resType pointer.
+ * Note: Caller should invoke OICFree after done with resType pointer.
  *
  * @param payload Presence payload.
  * @param seqNum Sequence number.
@@ -455,7 +455,7 @@ uint32_t GetTicks(uint32_t afterMilliSeconds)
 /**
  * Clones a string IFF its pointer value is not NULL.
  *
- * Note: The caller to this function is responsible for calling @ref OCFree
+ * Note: The caller to this function is responsible for calling @ref OICFree
  * for the destination parameter.
  *
  * @param dest The destination string for the string value to be cloned.
@@ -466,7 +466,7 @@ OCStackResult CloneStringIfNonNull(char **dest, const char *src)
 {
     if (src)
     {
-        *dest = (char*) OCMalloc(strlen(src) + 1);
+        *dest = (char*) OICMalloc(strlen(src) + 1);
         if (!*dest)
         {
             return OC_STACK_NO_MEMORY;
@@ -725,7 +725,7 @@ OCStackResult UpdateResponseAddr(OCDevAddr *address, const CARemoteEndpoint_t* e
     OCStackResult ret = OC_STACK_ERROR;
     char * tok = NULL;
     char * savePtr = NULL;
-    char * cpAddress = (char *) OCMalloc(strlen(endPoint->addressInfo.IP.ipAddress) + 1);
+    char * cpAddress = (char *) OICMalloc(strlen(endPoint->addressInfo.IP.ipAddress) + 1);
     if(!cpAddress)
     {
         ret = OC_STACK_NO_MEMORY;
@@ -751,7 +751,7 @@ OCStackResult UpdateResponseAddr(OCDevAddr *address, const CARemoteEndpoint_t* e
     ret = OC_STACK_OK;
 
 exit:
-    OCFree(cpAddress);
+    OICFree(cpAddress);
     return ret;
 }
 
@@ -907,7 +907,7 @@ void parsePresencePayload(char* payload, uint32_t* seqNum, uint32_t* maxAge,
                 if(resObj)
                 {
                     size = strlen(resObj->valuestring) + 1;
-                    *resType = (char *)OCMalloc(size);
+                    *resType = (char *)OICMalloc(size);
                     if(!*resType)
                     {
                         goto exit;
@@ -925,7 +925,7 @@ void parsePresencePayload(char* payload, uint32_t* seqNum, uint32_t* maxAge,
             {
                 OC_LOG(ERROR, TAG, PCF("JSON Presence Object not found in"
                         " Presence Payload."));
-                OCFree(*resType);
+                OICFree(*resType);
                 goto exit;
             }
         }
@@ -933,7 +933,7 @@ void parsePresencePayload(char* payload, uint32_t* seqNum, uint32_t* maxAge,
         {
             OC_LOG(ERROR, TAG, PCF("JSON Presence Payload does not contain a"
                                     " valid \"oic\" JSON representation."));
-            OCFree(*resType);
+            OICFree(*resType);
             goto exit;
         }
     }
@@ -941,7 +941,7 @@ void parsePresencePayload(char* payload, uint32_t* seqNum, uint32_t* maxAge,
     {
         OC_LOG(ERROR, TAG, PCF("JSON Presence Payload does map to a valid JSON"
                 " representation."));
-        OCFree(*resType);
+        OICFree(*resType);
         goto exit;
     }
 
@@ -972,7 +972,7 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
         return OC_STACK_ERROR;
     }
 
-    fullUri = (char *) OCMalloc(MAX_URI_LENGTH);
+    fullUri = (char *) OICMalloc(MAX_URI_LENGTH);
 
     if(!fullUri)
     {
@@ -982,7 +982,7 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
     }
 
     addressLen = strlen(endPoint->addressInfo.IP.ipAddress);
-    ipAddress = (char *) OCMalloc(addressLen + 1);
+    ipAddress = (char *) OICMalloc(addressLen + 1);
 
     if(!ipAddress)
     {
@@ -1075,8 +1075,8 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
             response.result = OC_STACK_PRESENCE_STOPPED;
             if(cbNode->presence)
             {
-                OCFree(cbNode->presence->timeOut);
-                OCFree(cbNode->presence);
+                OICFree(cbNode->presence->timeOut);
+                OICFree(cbNode->presence);
                 cbNode->presence = NULL;
             }
         }
@@ -1084,7 +1084,7 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
         {
             if(!cbNode->presence)
             {
-                cbNode->presence = (OCPresence *) OCMalloc(sizeof(OCPresence));
+                cbNode->presence = (OCPresence *) OICMalloc(sizeof(OCPresence));
                 if(!(cbNode->presence))
                 {
                     OC_LOG(ERROR, TAG, PCF("Could not allocate memory for cbNode->presence"));
@@ -1095,11 +1095,11 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
                 VERIFY_NON_NULL_V(cbNode->presence);
                 cbNode->presence->timeOut = NULL;
                 cbNode->presence->timeOut = (uint32_t *)
-                        OCMalloc(PresenceTimeOutSize * sizeof(uint32_t));
+                        OICMalloc(PresenceTimeOutSize * sizeof(uint32_t));
                 if(!(cbNode->presence->timeOut)){
                     OC_LOG(ERROR, TAG,
                                   PCF("Could not allocate memory for cbNode->presence->timeOut"));
-                    OCFree(cbNode->presence);
+                    OICFree(cbNode->presence);
                     result = OC_STACK_NO_MEMORY;
                     goto exit;
                 }
@@ -1144,7 +1144,7 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
         else
         {
             uint32_t uriLen = strlen(fullUri);
-            char* uri = (char *) OCMalloc(uriLen + 1);
+            char* uri = (char *) OICMalloc(uriLen + 1);
             if(uri)
             {
                 memcpy(uri, fullUri, (uriLen + 1));
@@ -1161,7 +1161,7 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
             {
                 OC_LOG(ERROR, TAG,
                     PCF("Unable to add Multicast Presence Node"));
-                OCFree(uri);
+                OICFree(uri);
                 goto exit;
             }
         }
@@ -1184,9 +1184,9 @@ static OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
     }
 
 exit:
-OCFree(fullUri);
-OCFree(ipAddress);
-OCFree(resourceTypeName);
+OICFree(fullUri);
+OICFree(ipAddress);
+OICFree(resourceTypeName);
 return result;
 }
 
@@ -1515,13 +1515,13 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
     {
         //copy URI
         memcpy (&(serverRequest.resourceUrl), newUri, strlen(newUri));
-        OCFree(newUri);
+        OICFree(newUri);
     }
     else
     {
         OC_LOG(ERROR, TAG, PCF("URI length exceeds MAX_URI_LENGTH."));
-        OCFree(newUri);
-        OCFree(query);
+        OICFree(newUri);
+        OICFree(query);
         return;
     }
     //copy query
@@ -1530,12 +1530,12 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
         if(strlen(query) < MAX_QUERY_LENGTH)
         {
             memcpy (&(serverRequest.query), query, strlen(query));
-            OCFree(query);
+            OICFree(query);
         }
         else
         {
             OC_LOG(ERROR, TAG, PCF("Query length exceeds MAX_QUERY_LENGTH."));
-            OCFree(query);
+            OICFree(query);
             return;
         }
     }
@@ -1590,7 +1590,7 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
             requestInfo->info.tokenLength);
     OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)requestInfo->info.token,
             requestInfo->info.tokenLength);
-    serverRequest.requestToken = (CAToken_t)OCMalloc(requestInfo->info.tokenLength);
+    serverRequest.requestToken = (CAToken_t)OICMalloc(requestInfo->info.tokenLength);
     serverRequest.tokenLength = requestInfo->info.tokenLength;
     // Module Name
     if (!serverRequest.requestToken)
@@ -1634,7 +1634,7 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
                 requestInfo->info.type, requestInfo->info.numOptions,
                 requestInfo->info.options, requestInfo->info.token,
                 requestInfo->info.tokenLength);
-        OCFree(serverRequest.requestToken);
+        OICFree(serverRequest.requestToken);
         return;
     }
     serverRequest.numRcvdVendorSpecificHeaderOptions = tempNum;
@@ -1665,7 +1665,7 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
     }
     // requestToken is fed to HandleStackRequests, which then goes to AddServerRequest.
     // The token is copied in there, and is thus still owned by this function.
-    OCFree(serverRequest.requestToken);
+    OICFree(serverRequest.requestToken);
     OC_LOG(INFO, TAG, PCF("Exit HandleCARequests"));
 }
 
@@ -2087,7 +2087,7 @@ OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requ
         if(query)
         {
             result = getResourceType((char *) query, &resourceType);
-            OCFree(query);
+            OICFree(query);
             if(resourceType)
             {
                 OC_LOG_V(DEBUG, TAG, "Got Resource Type: %s", resourceType);
@@ -2108,7 +2108,7 @@ OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requ
     }
 #endif // WITH_PRESENCE
 
-    requestUri = (char *) OCMalloc(uriLen + 1);
+    requestUri = (char *) OICMalloc(uriLen + 1);
     if(requestUri)
     {
         memcpy(requestUri, newUri, (uriLen + 1));
@@ -2176,7 +2176,7 @@ OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requ
     {
         grpEnd.transportType = caConType;
 
-        grpEnd.resourceUri = (CAURI_t) OCMalloc(uriLen + 1);
+        grpEnd.resourceUri = (CAURI_t) OICMalloc(uriLen + 1);
         if(!grpEnd.resourceUri)
         {
             result = OC_STACK_NO_MEMORY;
@@ -2227,24 +2227,24 @@ OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requ
 exit:
     if(newUri != requiredUri)
     {
-        OCFree(newUri);
+        OICFree(newUri);
     }
     if (result != OC_STACK_OK)
     {
         OC_LOG_V(ERROR, TAG, PCF("OCDoResource error no %d"), result);
         FindAndDeleteClientCB(clientCB);
-        OCFree(resHandle);
-        OCFree(requestUri);
-        OCFree(resourceType);
+        OICFree(resHandle);
+        OICFree(requestUri);
+        OICFree(resourceType);
     }
     CADestroyRemoteEndpoint(endpoint);
-    OCFree(grpEnd.resourceUri);
+    OICFree(grpEnd.resourceUri);
 
     if (requestData.options  && requestData.numOptions > 0)
     {
         if ((method == OC_REST_OBSERVE) || (method == OC_REST_OBSERVE_ALL))
         {
-            OCFree(requestData.options);
+            OICFree(requestData.options);
         }
     }
     return result;
@@ -2356,7 +2356,7 @@ OCStackResult OCCancel(OCDoHandle handle, OCQualityOfService qos, OCHeaderOption
     CADestroyRemoteEndpoint(endpoint);
     if (requestData.numOptions > 0)
     {
-        OCFree(requestData.options);
+        OICFree(requestData.options);
     }
 
     return ret;
@@ -2675,7 +2675,7 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
         }
     }
     // Create the pointer and insert it into the resource list
-    pointer = (OCResource *) OCCalloc(1, sizeof(OCResource));
+    pointer = (OCResource *) OICCalloc(1, sizeof(OCResource));
     if (!pointer)
     {
         result = OC_STACK_NO_MEMORY;
@@ -2687,7 +2687,7 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
 
     // Set the uri
     size = strlen(uri) + 1;
-    str = (char *) OCMalloc(size);
+    str = (char *) OICMalloc(size);
     if (!str)
     {
         result = OC_STACK_NO_MEMORY;
@@ -2742,7 +2742,7 @@ exit:
     {
         // Deep delete of resource and other dynamic elements that it contains
         deleteResource(pointer);
-        OCFree(str);
+        OICFree(str);
     }
     return result;
 }
@@ -2870,7 +2870,7 @@ OCStackResult BindResourceTypeToResource(OCResource* resource,
     // Is it presented during resource discovery?
 
     // Create the resourcetype and insert it into the resource list
-    pointer = (OCResourceType *) OCCalloc(1, sizeof(OCResourceType));
+    pointer = (OCResourceType *) OICCalloc(1, sizeof(OCResourceType));
     if (!pointer)
     {
         result = OC_STACK_NO_MEMORY;
@@ -2879,7 +2879,7 @@ OCStackResult BindResourceTypeToResource(OCResource* resource,
 
     // Set the resourceTypeName
     size = strlen(resourceTypeName) + 1;
-    str = (char *) OCMalloc(size);
+    str = (char *) OICMalloc(size);
     if (!str)
     {
         result = OC_STACK_NO_MEMORY;
@@ -2894,8 +2894,8 @@ OCStackResult BindResourceTypeToResource(OCResource* resource,
     exit:
     if (result != OC_STACK_OK)
     {
-        OCFree(pointer);
-        OCFree(str);
+        OICFree(pointer);
+        OICFree(str);
     }
 
     return result;
@@ -2917,7 +2917,7 @@ OCStackResult BindResourceInterfaceToResource(OCResource* resource,
     //TODO ("Make sure that the resourceinterface name doesn't already exist in the resource");
 
     // Create the resourceinterface and insert it into the resource list
-    pointer = (OCResourceInterface *) OCCalloc(1, sizeof(OCResourceInterface));
+    pointer = (OCResourceInterface *) OICCalloc(1, sizeof(OCResourceInterface));
     if (!pointer)
     {
         result = OC_STACK_NO_MEMORY;
@@ -2926,7 +2926,7 @@ OCStackResult BindResourceInterfaceToResource(OCResource* resource,
 
     // Set the resourceinterface name
     size = strlen(resourceInterfaceName) + 1;
-    str = (char *) OCMalloc(size);
+    str = (char *) OICMalloc(size);
     if (!str)
     {
         result = OC_STACK_NO_MEMORY;
@@ -2943,8 +2943,8 @@ OCStackResult BindResourceInterfaceToResource(OCResource* resource,
     exit:
     if (result != OC_STACK_OK)
     {
-        OCFree(pointer);
-        OCFree(str);
+        OICFree(pointer);
+        OICFree(str);
     }
 
     return result;
@@ -3415,7 +3415,7 @@ static OCDoHandle GenerateInvocationHandle()
 {
     OCDoHandle handle = NULL;
     // Generate token here, it will be deleted when the transaction is deleted
-    handle = (OCDoHandle) OCMalloc(sizeof(uint8_t[CA_MAX_TOKEN_LEN]));
+    handle = (OCDoHandle) OICMalloc(sizeof(uint8_t[CA_MAX_TOKEN_LEN]));
     if (handle)
     {
         OCFillRandomMem((uint8_t*)handle, sizeof(uint8_t[CA_MAX_TOKEN_LEN]));
@@ -3579,7 +3579,7 @@ OCStackResult deleteResource(OCResource *resource)
             }
 
             deleteResourceElements(temp);
-            OCFree(temp);
+            OICFree(temp);
             return OC_STACK_OK;
         }
         else
@@ -3600,7 +3600,7 @@ void deleteResourceElements(OCResource *resource)
     }
 
     // remove URI
-    OCFree(resource->uri);
+    OICFree(resource->uri);
 
     // Delete resourcetype linked list
     deleteResourceType(resource->rsrcType);
@@ -3617,8 +3617,8 @@ void deleteResourceType(OCResourceType *resourceType)
     while (pointer)
     {
         next = pointer->next;
-        OCFree(pointer->resourcetypename);
-        OCFree(pointer);
+        OICFree(pointer->resourcetypename);
+        OICFree(pointer);
         pointer = next;
     }
 }
@@ -3631,8 +3631,8 @@ void deleteResourceInterface(OCResourceInterface *resourceInterface)
     while (pointer)
     {
         next = pointer->next;
-        OCFree(pointer->name);
-        OCFree(pointer);
+        OICFree(pointer->name);
+        OICFree(pointer);
         pointer = next;
     }
 }
@@ -3659,8 +3659,8 @@ void insertResourceType(OCResource *resource, OCResourceType *resourceType)
             // resource type already exists. Free 2nd arg and return.
             if (!strcmp(resourceType->resourcetypename, pointer->resourcetypename))
             {
-                OCFree(resourceType->resourcetypename);
-                OCFree(resourceType);
+                OICFree(resourceType->resourcetypename);
+                OICFree(resourceType);
                 return;
             }
             previous = pointer;
@@ -3740,8 +3740,8 @@ void insertResourceInterface(OCResource *resource, OCResourceInterface *newInter
     {
         if (strcmp((*firstInterface)->name, OC_RSRVD_INTERFACE_DEFAULT) == 0)
         {
-            OCFree(newInterface->name);
-            OCFree(newInterface);
+            OICFree(newInterface->name);
+            OICFree(newInterface);
             return;
         }
         else
@@ -3757,8 +3757,8 @@ void insertResourceInterface(OCResource *resource, OCResourceInterface *newInter
         {
             if (strcmp(newInterface->name, pointer->name) == 0)
             {
-                OCFree(newInterface->name);
-                OCFree(newInterface);
+                OICFree(newInterface->name);
+                OICFree(newInterface);
                 return;
             }
             previous = pointer;
@@ -3834,7 +3834,7 @@ OCStackResult getResourceType(const char * query, char** resourceType)
 
     if(strncmp(query, "rt=", 3) == 0)
     {
-        *resourceType = (char *) OCMalloc(strlen(query)-3 + 1);
+        *resourceType = (char *) OICMalloc(strlen(query)-3 + 1);
         if(!*resourceType)
         {
             result = OC_STACK_NO_MEMORY;
@@ -3887,7 +3887,7 @@ OCStackResult getQueryFromUri(const char * uri, char** query, char ** uriWithout
 
     if (uriWithoutQueryLen)
     {
-        *uriWithoutQuery =  (char *) OCCalloc(uriWithoutQueryLen + 1, 1);
+        *uriWithoutQuery =  (char *) OICCalloc(uriWithoutQueryLen + 1, 1);
         if (!*uriWithoutQuery)
         {
             goto exit;
@@ -3901,10 +3901,10 @@ OCStackResult getQueryFromUri(const char * uri, char** query, char ** uriWithout
 
     if (queryLen)
     {
-        *query = (char *) OCCalloc(queryLen + 1, 1);
+        *query = (char *) OICCalloc(queryLen + 1, 1);
         if (!*query)
         {
-            OCFree(*uriWithoutQuery);
+            OICFree(*uriWithoutQuery);
             *uriWithoutQuery = NULL;
             goto exit;
         }
index 741ebf5..65f4ff4 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "oicgroup.h"
 #include "cJSON.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
 #include "occollection.h"
 #include "logger.h"
 #include "timer.h"
@@ -62,7 +62,7 @@
 
 #define OCFREE(pointer) \
     { \
-        OCFree(pointer); \
+        OICFree(pointer); \
         pointer = NULL; \
     }
 
@@ -539,7 +539,7 @@ OCStackResult ExtractKeyValueFromRequest(char *request, char **key,
     VARIFY_POINTER_NULL(iterToken, result, exit);
     length = strlen(iterToken) + 1;
 
-    *key = (char *) OCMalloc(length);
+    *key = (char *) OICMalloc(length);
     VARIFY_POINTER_NULL(*key, result, exit)
 
     strncpy(*key, iterToken + 1, length);
@@ -549,7 +549,7 @@ OCStackResult ExtractKeyValueFromRequest(char *request, char **key,
     VARIFY_POINTER_NULL(iterToken, result, exit);
     length = strlen(iterToken) + 1;
 
-    *value = (char *) OCMalloc(length);
+    *value = (char *) OICMalloc(length);
     VARIFY_POINTER_NULL(*value, result, exit)
 
     strncpy(*value, iterToken + 1, length);
@@ -572,7 +572,7 @@ OCStackResult ExtractActionSetNameAndDelaytime(char *pChar, char **setName,
     OCStackResult result = OC_STACK_OK;
 
     token = (char*) strtok_r(pChar, ACTION_DELIMITER, &tokenPtr);
-    *setName = (char *) OCMalloc(strlen(token) + 1);
+    *setName = (char *) OICMalloc(strlen(token) + 1);
     VARIFY_POINTER_NULL(*setName, result, exit)
     VARIFY_PARAM_NULL(token, result, exit)
     strncpy(*setName, token, strlen(token) + 1);
@@ -604,14 +604,14 @@ OCStackResult BuildActionSetFromString(OCActionSet **set, char* actiondesc)
 
     OC_LOG(INFO, TAG, PCF("Build ActionSet Instance."));
 
-    *set = (OCActionSet*) OCMalloc(sizeof(OCActionSet));
+    *set = (OCActionSet*) OICMalloc(sizeof(OCActionSet));
     VARIFY_POINTER_NULL(*set, result, exit)
 
     iterToken = (char *) strtok_r(actiondesc, ACTION_DELIMITER, &iterTokenPtr);
 
     // ActionSet Name
     memset(*set, 0, sizeof(OCActionSet));
-    (*set)->actionsetName = (char *) OCMalloc(strlen(iterToken) + 1);
+    (*set)->actionsetName = (char *) OICMalloc(strlen(iterToken) + 1);
     VARIFY_POINTER_NULL((*set)->actionsetName, result, exit)
     VARIFY_PARAM_NULL(iterToken, result, exit)
     strncpy((*set)->actionsetName, iterToken, strlen(iterToken) + 1);
@@ -631,7 +631,7 @@ OCStackResult BuildActionSetFromString(OCActionSet **set, char* actiondesc)
     iterToken = (char *) strtok_r(NULL, ACTION_DELIMITER, &iterTokenPtr);
     while (iterToken)
     {
-        desc = (char *) OCMalloc(strlen(iterToken) + 1);
+        desc = (char *) OICMalloc(strlen(iterToken) + 1);
         VARIFY_POINTER_NULL(desc, result, exit)
         VARIFY_PARAM_NULL(desc, result, exit)
         strncpy(desc, iterToken, strlen(iterToken) + 1);
@@ -639,21 +639,21 @@ OCStackResult BuildActionSetFromString(OCActionSet **set, char* actiondesc)
                 &descIterTokenPtr);
         while (descIterToken)
         {
-            attr = (char *) OCMalloc(strlen(descIterToken) + 1);
+            attr = (char *) OICMalloc(strlen(descIterToken) + 1);
             VARIFY_POINTER_NULL(attr, result, exit)
             VARIFY_PARAM_NULL(descIterToken, result, exit)
             strncpy(attr, descIterToken, strlen(descIterToken) + 1);
 
             attrIterToken = (char *) strtok_r(attr, ATTR_ASSIGN,
                     &attrIterTokenPtr);
-            key = (char *) OCMalloc(strlen(attrIterToken) + 1);
+            key = (char *) OICMalloc(strlen(attrIterToken) + 1);
             VARIFY_POINTER_NULL(key, result, exit)
             VARIFY_PARAM_NULL(attrIterToken, result, exit)
             strncpy(key, attrIterToken, strlen(attrIterToken) + 1);
 
             attrIterToken = (char *) strtok_r(NULL, ATTR_ASSIGN,
                     &attrIterTokenPtr);
-            value = (char *) OCMalloc(strlen(attrIterToken) + 1);
+            value = (char *) OICMalloc(strlen(attrIterToken) + 1);
             VARIFY_POINTER_NULL(value, result, exit)
             VARIFY_PARAM_NULL(attrIterToken, result, exit)
             strncpy(value, attrIterToken, strlen(attrIterToken) + 1);
@@ -662,10 +662,10 @@ OCStackResult BuildActionSetFromString(OCActionSet **set, char* actiondesc)
             {
                 OC_LOG(INFO, TAG, PCF("Build OCAction Instance."));
 
-                action = (OCAction*) OCMalloc(sizeof(OCAction));
+                action = (OCAction*) OICMalloc(sizeof(OCAction));
                 VARIFY_POINTER_NULL(action, result, exit)
                 memset(action, 0, sizeof(OCAction));
-                action->resourceUri = (char *) OCMalloc(strlen(value) + 1);
+                action->resourceUri = (char *) OICMalloc(strlen(value) + 1);
                 VARIFY_POINTER_NULL(action->resourceUri, result, exit)
                 VARIFY_PARAM_NULL(value, result, exit)
                 strncpy(action->resourceUri, value, strlen(value) + 1);
@@ -676,16 +676,16 @@ OCStackResult BuildActionSetFromString(OCActionSet **set, char* actiondesc)
                 {
                     OC_LOG(INFO, TAG, PCF("Build OCCapability Instance."));
 
-                    capa = (OCCapability*) OCMalloc(sizeof(OCCapability));
+                    capa = (OCCapability*) OICMalloc(sizeof(OCCapability));
                     VARIFY_POINTER_NULL(capa, result, exit)
                     memset(capa, 0, sizeof(OCCapability));
 
-                    capa->capability = (char *) OCMalloc(strlen(key) + 1);
+                    capa->capability = (char *) OICMalloc(strlen(key) + 1);
                     VARIFY_POINTER_NULL(capa->capability, result, exit)
                     VARIFY_PARAM_NULL(key, result, exit)
                     strncpy(capa->capability, key, strlen(key) + 1);
 
-                    capa->status = (char *) OCMalloc(strlen(value) + 1);
+                    capa->status = (char *) OICMalloc(strlen(value) + 1);
                     VARIFY_POINTER_NULL(capa->status, result, exit)
                     VARIFY_PARAM_NULL(value, result, exit)
                     strncpy(capa->status, value, strlen(value) + 1);
@@ -778,7 +778,7 @@ OCStackResult BuildStringFromActionSet(OCActionSet* actionset, char** desc)
         }
     }
 
-    *desc = (char *) OCMalloc(1024 - remaining);
+    *desc = (char *) OICMalloc(1024 - remaining);
     VARIFY_POINTER_NULL(*desc, res, exit);
     strcpy(*desc, temp);
 
@@ -802,7 +802,7 @@ OCStackApplicationResult ActionSetCB(void* context, OCDoHandle handle,
         int idx;
 
         unsigned char *responseJson;
-        responseJson = (unsigned char *) OCMalloc(
+        responseJson = (unsigned char *) OICMalloc(
                 (unsigned int) (strlen((char *) clientResponse->resJSONPayload)
                         + 1));
 
@@ -931,7 +931,7 @@ OCStackResult DoAction(OCResource* resource, OCActionSet* actionset,
         strncat((char *) actionDescPtr, (const char *) OC_JSON_SUFFIX,
                 strlen((const char *) OC_JSON_SUFFIX));
 
-        ClientRequestInfo *info = (ClientRequestInfo *) OCMalloc(
+        ClientRequestInfo *info = (ClientRequestInfo *) OICMalloc(
                 sizeof(ClientRequestInfo));
 
         if( info == NULL )
@@ -993,7 +993,7 @@ void DoScheduledGroupAction()
     if (info->actionset->type == RECURSIVE)
     {
         ScheduledResourceInfo *schedule;
-        schedule = (ScheduledResourceInfo *) OCMalloc(
+        schedule = (ScheduledResourceInfo *) OICMalloc(
                 sizeof(ScheduledResourceInfo));
 
         if (schedule)
@@ -1204,7 +1204,7 @@ OCStackResult BuildCollectionGroupActionJSONResponse(
                                     (delay == -1 ? actionset->timesteps : delay);
 
                             ScheduledResourceInfo *schedule;
-                            schedule = (ScheduledResourceInfo *) OCMalloc(
+                            schedule = (ScheduledResourceInfo *) OICMalloc(
                                     sizeof(ScheduledResourceInfo));
 
                             if (schedule)
@@ -1274,7 +1274,7 @@ OCStackResult BuildCollectionGroupActionJSONResponse(
                     {
                         cJSON_AddStringToObject(format, ACTIONSET, plainText);
                     }
-                    OCFree(plainText);
+                    OICFree(plainText);
                     stackRet = OC_STACK_OK;
                 }
             }
index 82c6e09..1fe5464 100644 (file)
@@ -36,7 +36,6 @@ stacktest_env.PrependUnique(CPPPATH = [
                '../../stack/include',
                '../../stack/include/internal',
                '../../connectivity/api',
-               '../../ocmalloc/include',
                '../../extlibs/cjson',
                '../../../oc_logger/include',
                '../../../../extlibs/gtest/gtest-1.7.0/include'
index bfa4be8..1e3d93f 100644 (file)
@@ -24,7 +24,7 @@ extern "C"
     #include "ocstack.h"
     #include "ocstackinternal.h"
     #include "logger.h"
-    #include "ocmalloc.h"
+    #include "oic_malloc.h"
 }
 
 #include "gtest/gtest.h"
@@ -1493,7 +1493,7 @@ TEST(StackPresence, ParsePresencePayload)
     EXPECT_TRUE(OC_PRESENCE_TRIGGER_DELETE == presenceTrigger);
     EXPECT_TRUE(NULL != resType);
     EXPECT_STREQ("presence", resType);
-    OCFree(resType);
+    OICFree(resType);
 
     presenceTrigger = OC_PRESENCE_TRIGGER_CHANGE;
 
@@ -1509,7 +1509,7 @@ TEST(StackPresence, ParsePresencePayload)
     EXPECT_TRUE(OC_PRESENCE_TRIGGER_CHANGE == presenceTrigger);
     EXPECT_TRUE(NULL == resType);
     EXPECT_EQ(NULL, resType);
-    OCFree(resType);
+    OICFree(resType);
 
     //Bad Scenario
     seqNum = 0; maxAge = 0; resType = NULL;
@@ -1520,7 +1520,7 @@ TEST(StackPresence, ParsePresencePayload)
     EXPECT_TRUE(OC_PRESENCE_TRIGGER_CHANGE == presenceTrigger);
     EXPECT_TRUE(NULL == resType);
     EXPECT_EQ(NULL, resType);
-    OCFree(resType);
+    OICFree(resType);
 
     //Bad Scenario
     seqNum = 0; maxAge = 0; resType = NULL;
@@ -1531,7 +1531,7 @@ TEST(StackPresence, ParsePresencePayload)
     EXPECT_TRUE(OC_PRESENCE_TRIGGER_CHANGE == presenceTrigger);
     EXPECT_TRUE(NULL == resType);
     EXPECT_EQ(NULL, resType);
-    OCFree(resType);
+    OICFree(resType);
 
     //Bad Scenario
     strncpy(payload, "{:]}", sizeof(payload));
@@ -1541,7 +1541,7 @@ TEST(StackPresence, ParsePresencePayload)
     EXPECT_TRUE(OC_PRESENCE_TRIGGER_CHANGE == presenceTrigger);
     EXPECT_TRUE(NULL == resType);
     EXPECT_EQ(NULL, resType);
-    OCFree(resType);
+    OICFree(resType);
 
     //Bad Scenario
     strncpy(payload, "{:[presence}", sizeof(payload));
@@ -1551,7 +1551,7 @@ TEST(StackPresence, ParsePresencePayload)
     EXPECT_TRUE(OC_PRESENCE_TRIGGER_CHANGE == presenceTrigger);
     EXPECT_TRUE(NULL == resType);
     EXPECT_EQ(NULL, resType);
-    OCFree(resType);
+    OICFree(resType);
 }
 
 TEST(PODTests, OCHeaderOption)
index 4ab5086..8d38f28 100644 (file)
@@ -108,14 +108,16 @@ INPUT                  = devdox \
                          ../csdk/connectivity/src \
                          ../csdk/logger/include \
                          ../csdk/logger/src \
-                         ../csdk/ocmalloc/include \
-                         ../csdk/ocmalloc/src \
                          ../csdk/ocrandom/include \
                          ../csdk/ocrandom/src \
                          ../csdk/security/include \
                          ../csdk/security/src \
                          ../csdk/stack/include \
-                         ../csdk/stack/src
+                         ../csdk/stack/src \
+                         ../c_common/oic_malloc/include \
+                         ../c_common/oic_malloc/src \
+                         ../c_common/oic_string/include \
+                         ../c_common/oic_string/src
 
 INPUT_ENCODING         = UTF-8
 FILE_PATTERNS          =
index 0c31217..6b6d8b6 100644 (file)
@@ -33,7 +33,7 @@
 #include <OCResourceResponse.h>
 #include <ocstack.h>
 #include <OCApi.h>
-#include <ocmalloc.h>
+#include <oic_malloc.h>
 #include <OCPlatform.h>
 #include <OCUtilities.h>
 
@@ -534,7 +534,7 @@ namespace OC
             response.resourceHandle = pResponse->getResourceHandle();
             response.ehResult = pResponse->getResponseResult();
 
-            response.payload = static_cast<char*>(OCMalloc(payLoad.length() + 1));
+            response.payload = static_cast<char*>(OICMalloc(payLoad.length() + 1));
             if(!response.payload)
             {
                 result = OC_STACK_NO_MEMORY;
@@ -575,7 +575,7 @@ namespace OC
             }
             else
             {
-                OCFree(response.payload);
+                OICFree(response.payload);
                 result = OC_STACK_ERROR;
             }
 
index 2e2c94f..fba709a 100644 (file)
@@ -35,7 +35,6 @@ oclib_env.AppendUnique(CPPPATH = [
                '../include/',
                '../csdk/stack/include',
                '../csdk/ocrandom/include',
-               '../csdk/ocmalloc/include',
                '../csdk/logger/include',
                '../oc_logger/include',
                '../csdk/connectivity/lib/libcoap-4.1.1'
index 41a10bc..a5f1368 100644 (file)
@@ -38,6 +38,10 @@ if target_os == 'linux':
        # get it and install it
        SConscript(src_dir + '/extlibs/hippomocks.scons')
 
+    # Build Common unit tests
+       SConscript('c_common/oic_string/test/SConscript')
+       SConscript('c_common/oic_malloc/test/SConscript')
+
        # Build C unit tests
        SConscript('csdk/stack/test/SConscript')
        SConscript('csdk/ocrandom/test/SConscript')