# 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')
--- /dev/null
+#******************************************************************
+#
+# 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')
--- /dev/null
+#******************************************************************
+#
+# 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')
extern "C" {
- #include "ocmalloc.h"
+ #include "oic_malloc.h"
}
#include "gtest/gtest.h"
// 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);
}
#include <string.h>
#include <assert.h>
-#include "logger.h"
#include "oic_malloc.h"
#define TAG "OIC_STRING"
--- /dev/null
+#******************************************************************
+#
+# 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')
'../../extlibs/timer/',
'logger/include',
'ocrandom/include',
- 'ocmalloc/include',
'stack/include',
'stack/include/internal',
'../oc_logger/include',
if env.get('LOGGING'):
liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+liboctbstack_env.Append(LIBS = ['c_common'])
+
######################################################################
# Source files and Targets
######################################################################
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')
# 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',
]
'../../ocsocket/include',
'../../logger/include',
'../../stack/include',
- '../../ocmalloc/include',
'../../extlibs/cjson',
'../../../oc_logger/include',
'../../../../extlibs/gtest/gtest-1.7.0/include'
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])
# 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
INPUT = . \
../stack/include \
../ocsocket/include \
- ../ocmalloc/include \
../ocrandom/include \
../occoap/include \
+++ /dev/null
-//******************************************************************
-//
-// 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_ */
+++ /dev/null
-//******************************************************************
-//
-// 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);
-}
-
+++ /dev/null
--------------------------------------------------------------------------------
- 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
randomtest_env.PrependUnique(CPPPATH = [
'../include',
'../../logger/include',
- '../../ocmalloc/include',
'../../../oc_logger/include',
'../../../../extlibs/gtest/gtest-1.7.0/include'
])
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "ocstack.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include "ocsecurity.h"
#include "ocsecurityconfig.h"
#include "cainterface.h"
// Initialize sensitive data to zeroes before freeing.
memset(secConfigData, 0, secConfigDataLen);
- OCFree(secConfigData);
+ OICFree(secConfigData);
secConfigData = NULL;
}
}
* 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
{
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;
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,
// Clear memory if any memory allocation failed above
if(caBlob)
{
- OCFree(caBlob->creds);
- OCFree(caBlob);
+ OICFree(caBlob->creds);
+ OICFree(caBlob);
}
}
#endif //__WITH_DTLS__
// Remove existing blob
DeinitOCSecurityInfo();
// Allocate storage for new blob
- secConfigData = (OCSecConfigData*)OCMalloc(len);
+ secConfigData = (OCSecConfigData*)OICMalloc(len);
if (secConfigData)
{
memcpy(secConfigData, cfgData, len);
samples_env.PrependUnique(CPPPATH = [
'../../../../logger/include',
'../../../../stack/include',
- '../../../../ocmalloc/include',
'../../../../../../extlibs/cjson',
'../../../../../oc_logger/include',
'../../../../../connectivity/lib/libcoap-4.1.1'
#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)
}
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);
}
}
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);
}
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);
}
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;
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);
}
!= OC_STACK_OK)
{
OC_LOG(ERROR, TAG, "Error while parsing JSON payload in OCClientResponse");
- OCFree(sid);
- OCFree(uri);
+ OICFree(sid);
+ OICFree(uri);
return;
}
}
}
- OCFree(sid);
- OCFree(uri);
+ OICFree(sid);
+ OICFree(uri);
}
/* This function searches for the resource(sid:uri) in the ResourceList.
}
//Creating new ResourceNode
- if((iter = (ResourceNode *) OCMalloc(sizeof(ResourceNode))))
+ if((iter = (ResourceNode *) OICMalloc(sizeof(ResourceNode))))
{
iter->sid = sid;
iter->uri = uri;
{
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);
}
}
#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"
{
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)
{
}
else
{
- OCFree(request->query);
- OCFree(request);
+ OICFree(request->query);
+ OICFree(request);
request = NULL;
}
}
else
{
- OCFree(request);
+ OICFree(request);
request = NULL;
}
}
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())
{
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();
}
#include "occlientcb.h"
#include "utlist.h"
#include "logger.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include <string.h>
#ifdef WITH_ARDUINO
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;
cbData->cd(cbData->context);
}
- OCFree(token);
- OCFree(*handle);
- OCFree(requestUri);
+ OICFree(token);
+ OICFree(*handle);
+ OICFree(requestUri);
*handle = cbNode->handle;
}
}
else
{
- OCFree(resourceTypeName);
+ OICFree(resourceTypeName);
}
#else
- OCFree(resourceTypeName);
+ OICFree(resourceTypeName);
#endif
return OC_STACK_OK;
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);
#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)
{
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;
}
}
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;
OCMulticastNode *node;
- node = (OCMulticastNode*) OCMalloc(sizeof(OCMulticastNode));
+ node = (OCMulticastNode*) OICMalloc(sizeof(OCMulticastNode));
if (node)
{
#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>
}
cJSON_Delete (resObj);
- OCFree(jsonStr);
+ OICFree(jsonStr);
return ret;
}
#include "ocobserve.h"
#include "ocresourcehandler.h"
#include "ocrandom.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include "ocserverrequest.h"
#include "cJSON.h"
ret = OC_STACK_ERROR;
}
- OCFree(jsonStr);
+ OICFree(jsonStr);
}
else
{
{
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);
// Increment only if OCDoResponse is successful
numSentNotification++;
- OCFree(ehResponse.payload);
+ OICFree(ehResponse.payload);
FindAndDeleteServerRequest(request);
}
else
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);
}
// 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);
}
exit:
if (obsNode)
{
- OCFree(obsNode->resUri);
- OCFree(obsNode->query);
- OCFree(obsNode);
+ OICFree(obsNode->resUri);
+ OICFree(obsNode->query);
+ OICFree(obsNode);
}
return OC_STACK_NO_MEMORY;
}
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;
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;
#include "ocresourcehandler.h"
#include "ocobserve.h"
#include "occollection.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include "logger.h"
#include "cJSON.h"
}
}
- OCFree(info);
+ OICFree(info);
return ret;
}
ret = OC_STACK_ERROR;
}
cJSON_Delete (resObj);
- OCFree (jsonStr);
+ OICFree (jsonStr);
OC_LOG(INFO, TAG, PCF("Exiting BuildVirtualResourceResponse"));
return ret;
ret = OC_STACK_ERROR;
}
- OCFree(jsonStr);
+ OICFree(jsonStr);
}
else
{
OC_LOG_V(ERROR, TAG, PCF("Platform info string too big. len: %u"), jsonLen);
ret = OC_STACK_ERROR;
}
- OCFree(jsonStr);
+ OICFree(jsonStr);
}
else
{
{
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;
}
{
OC_LOG(INFO, TAG, PCF("Deleting device info."));
- OCFree(savedDeviceInfo.deviceName);
+ OICFree(savedDeviceInfo.deviceName);
savedDeviceInfo.deviceName = NULL;
}
#include "ocstack.h"
#include "ocserverrequest.h"
#include "ocresourcehandler.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include "cacommon.h"
#include "cainterface.h"
{
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;
exit:
if (serverResponse)
{
- OCFree(serverResponse);
+ OICFree(serverResponse);
serverResponse = NULL;
}
*response = NULL;
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!!"));
}
if(serverResponse)
{
LL_DELETE(serverResponseList, serverResponse);
- OCFree(serverResponse->payload);
- OCFree(serverResponse);
+ OICFree(serverResponse->payload);
+ OICFree(serverResponse);
OC_LOG(INFO, TAG, PCF("Server Response Removed!!"));
}
}
//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);
// 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);
}
exit:
if (serverRequest)
{
- OCFree(serverRequest);
+ OICFree(serverRequest);
serverRequest = NULL;
}
*request = NULL;
}
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");
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;
}
}
#endif
- OCFree(responseInfo.info.token);
- OCFree(responseInfo.info.options);
+ OICFree(responseInfo.info.token);
+ OICFree(responseInfo.info.options);
//Delete the request
FindAndDeleteServerRequest(serverRequest);
return result;
#include "occlientcb.h"
#include "ocobserve.h"
#include "ocrandom.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include "ocserverrequest.h"
#include "ocsecurityinternal.h"
#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.
/**
* 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.
{
if (src)
{
- *dest = (char*) OCMalloc(strlen(src) + 1);
+ *dest = (char*) OICMalloc(strlen(src) + 1);
if (!*dest)
{
return OC_STACK_NO_MEMORY;
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;
ret = OC_STACK_OK;
exit:
- OCFree(cpAddress);
+ OICFree(cpAddress);
return ret;
}
if(resObj)
{
size = strlen(resObj->valuestring) + 1;
- *resType = (char *)OCMalloc(size);
+ *resType = (char *)OICMalloc(size);
if(!*resType)
{
goto exit;
{
OC_LOG(ERROR, TAG, PCF("JSON Presence Object not found in"
" Presence Payload."));
- OCFree(*resType);
+ OICFree(*resType);
goto exit;
}
}
{
OC_LOG(ERROR, TAG, PCF("JSON Presence Payload does not contain a"
" valid \"oic\" JSON representation."));
- OCFree(*resType);
+ OICFree(*resType);
goto exit;
}
}
{
OC_LOG(ERROR, TAG, PCF("JSON Presence Payload does map to a valid JSON"
" representation."));
- OCFree(*resType);
+ OICFree(*resType);
goto exit;
}
return OC_STACK_ERROR;
}
- fullUri = (char *) OCMalloc(MAX_URI_LENGTH);
+ fullUri = (char *) OICMalloc(MAX_URI_LENGTH);
if(!fullUri)
{
}
addressLen = strlen(endPoint->addressInfo.IP.ipAddress);
- ipAddress = (char *) OCMalloc(addressLen + 1);
+ ipAddress = (char *) OICMalloc(addressLen + 1);
if(!ipAddress)
{
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;
}
}
{
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"));
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;
}
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));
{
OC_LOG(ERROR, TAG,
PCF("Unable to add Multicast Presence Node"));
- OCFree(uri);
+ OICFree(uri);
goto exit;
}
}
}
exit:
-OCFree(fullUri);
-OCFree(ipAddress);
-OCFree(resourceTypeName);
+OICFree(fullUri);
+OICFree(ipAddress);
+OICFree(resourceTypeName);
return result;
}
{
//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
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;
}
}
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)
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;
}
// 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"));
}
if(query)
{
result = getResourceType((char *) query, &resourceType);
- OCFree(query);
+ OICFree(query);
if(resourceType)
{
OC_LOG_V(DEBUG, TAG, "Got Resource Type: %s", resourceType);
}
#endif // WITH_PRESENCE
- requestUri = (char *) OCMalloc(uriLen + 1);
+ requestUri = (char *) OICMalloc(uriLen + 1);
if(requestUri)
{
memcpy(requestUri, newUri, (uriLen + 1));
{
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;
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;
CADestroyRemoteEndpoint(endpoint);
if (requestData.numOptions > 0)
{
- OCFree(requestData.options);
+ OICFree(requestData.options);
}
return ret;
}
}
// 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;
// Set the uri
size = strlen(uri) + 1;
- str = (char *) OCMalloc(size);
+ str = (char *) OICMalloc(size);
if (!str)
{
result = OC_STACK_NO_MEMORY;
{
// Deep delete of resource and other dynamic elements that it contains
deleteResource(pointer);
- OCFree(str);
+ OICFree(str);
}
return result;
}
// 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;
// Set the resourceTypeName
size = strlen(resourceTypeName) + 1;
- str = (char *) OCMalloc(size);
+ str = (char *) OICMalloc(size);
if (!str)
{
result = OC_STACK_NO_MEMORY;
exit:
if (result != OC_STACK_OK)
{
- OCFree(pointer);
- OCFree(str);
+ OICFree(pointer);
+ OICFree(str);
}
return result;
//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;
// Set the resourceinterface name
size = strlen(resourceInterfaceName) + 1;
- str = (char *) OCMalloc(size);
+ str = (char *) OICMalloc(size);
if (!str)
{
result = OC_STACK_NO_MEMORY;
exit:
if (result != OC_STACK_OK)
{
- OCFree(pointer);
- OCFree(str);
+ OICFree(pointer);
+ OICFree(str);
}
return result;
{
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]));
}
deleteResourceElements(temp);
- OCFree(temp);
+ OICFree(temp);
return OC_STACK_OK;
}
else
}
// remove URI
- OCFree(resource->uri);
+ OICFree(resource->uri);
// Delete resourcetype linked list
deleteResourceType(resource->rsrcType);
while (pointer)
{
next = pointer->next;
- OCFree(pointer->resourcetypename);
- OCFree(pointer);
+ OICFree(pointer->resourcetypename);
+ OICFree(pointer);
pointer = next;
}
}
while (pointer)
{
next = pointer->next;
- OCFree(pointer->name);
- OCFree(pointer);
+ OICFree(pointer->name);
+ OICFree(pointer);
pointer = next;
}
}
// 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;
{
if (strcmp((*firstInterface)->name, OC_RSRVD_INTERFACE_DEFAULT) == 0)
{
- OCFree(newInterface->name);
- OCFree(newInterface);
+ OICFree(newInterface->name);
+ OICFree(newInterface);
return;
}
else
{
if (strcmp(newInterface->name, pointer->name) == 0)
{
- OCFree(newInterface->name);
- OCFree(newInterface);
+ OICFree(newInterface->name);
+ OICFree(newInterface);
return;
}
previous = pointer;
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;
if (uriWithoutQueryLen)
{
- *uriWithoutQuery = (char *) OCCalloc(uriWithoutQueryLen + 1, 1);
+ *uriWithoutQuery = (char *) OICCalloc(uriWithoutQueryLen + 1, 1);
if (!*uriWithoutQuery)
{
goto exit;
if (queryLen)
{
- *query = (char *) OCCalloc(queryLen + 1, 1);
+ *query = (char *) OICCalloc(queryLen + 1, 1);
if (!*query)
{
- OCFree(*uriWithoutQuery);
+ OICFree(*uriWithoutQuery);
*uriWithoutQuery = NULL;
goto exit;
}
#include "oicgroup.h"
#include "cJSON.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include "occollection.h"
#include "logger.h"
#include "timer.h"
#define OCFREE(pointer) \
{ \
- OCFree(pointer); \
+ OICFree(pointer); \
pointer = NULL; \
}
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);
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);
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);
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);
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);
&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);
{
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);
{
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);
}
}
- *desc = (char *) OCMalloc(1024 - remaining);
+ *desc = (char *) OICMalloc(1024 - remaining);
VARIFY_POINTER_NULL(*desc, res, exit);
strcpy(*desc, temp);
int idx;
unsigned char *responseJson;
- responseJson = (unsigned char *) OCMalloc(
+ responseJson = (unsigned char *) OICMalloc(
(unsigned int) (strlen((char *) clientResponse->resJSONPayload)
+ 1));
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 )
if (info->actionset->type == RECURSIVE)
{
ScheduledResourceInfo *schedule;
- schedule = (ScheduledResourceInfo *) OCMalloc(
+ schedule = (ScheduledResourceInfo *) OICMalloc(
sizeof(ScheduledResourceInfo));
if (schedule)
(delay == -1 ? actionset->timesteps : delay);
ScheduledResourceInfo *schedule;
- schedule = (ScheduledResourceInfo *) OCMalloc(
+ schedule = (ScheduledResourceInfo *) OICMalloc(
sizeof(ScheduledResourceInfo));
if (schedule)
{
cJSON_AddStringToObject(format, ACTIONSET, plainText);
}
- OCFree(plainText);
+ OICFree(plainText);
stackRet = OC_STACK_OK;
}
}
'../../stack/include',
'../../stack/include/internal',
'../../connectivity/api',
- '../../ocmalloc/include',
'../../extlibs/cjson',
'../../../oc_logger/include',
'../../../../extlibs/gtest/gtest-1.7.0/include'
#include "ocstack.h"
#include "ocstackinternal.h"
#include "logger.h"
- #include "ocmalloc.h"
+ #include "oic_malloc.h"
}
#include "gtest/gtest.h"
EXPECT_TRUE(OC_PRESENCE_TRIGGER_DELETE == presenceTrigger);
EXPECT_TRUE(NULL != resType);
EXPECT_STREQ("presence", resType);
- OCFree(resType);
+ OICFree(resType);
presenceTrigger = OC_PRESENCE_TRIGGER_CHANGE;
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;
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;
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));
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));
EXPECT_TRUE(OC_PRESENCE_TRIGGER_CHANGE == presenceTrigger);
EXPECT_TRUE(NULL == resType);
EXPECT_EQ(NULL, resType);
- OCFree(resType);
+ OICFree(resType);
}
TEST(PODTests, OCHeaderOption)
../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 =
#include <OCResourceResponse.h>
#include <ocstack.h>
#include <OCApi.h>
-#include <ocmalloc.h>
+#include <oic_malloc.h>
#include <OCPlatform.h>
#include <OCUtilities.h>
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;
}
else
{
- OCFree(response.payload);
+ OICFree(response.payload);
result = OC_STACK_ERROR;
}
'../include/',
'../csdk/stack/include',
'../csdk/ocrandom/include',
- '../csdk/ocmalloc/include',
'../csdk/logger/include',
'../oc_logger/include',
'../csdk/connectivity/lib/libcoap-4.1.1'
# 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')