You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/30 16:57:58 UTC
[10/16] incubator-mynewt-core git commit: oic;
remove oc_list, oc_mmem.
oic; remove oc_list, oc_mmem.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/049222d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/049222d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/049222d3
Branch: refs/heads/develop
Commit: 049222d3f1330fe9386f7829e61ee73cf167a6c6
Parents: 0526e07
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 30 08:18:12 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 30 08:45:24 2016 -0800
----------------------------------------------------------------------
net/oic/include/oic/oc_helpers.h | 2 -
net/oic/src/messaging/coap/observe.h | 2 -
net/oic/src/messaging/coap/oc_coap.h | 1 -
net/oic/src/messaging/coap/transactions.c | 1 -
net/oic/src/port/mynewt/config.h | 5 -
net/oic/src/util/oc_list.c | 317 -------------------------
net/oic/src/util/oc_list.h | 152 ------------
net/oic/src/util/oc_mmem.c | 154 ------------
net/oic/src/util/oc_mmem.h | 61 -----
9 files changed, 695 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/include/oic/oc_helpers.h
----------------------------------------------------------------------
diff --git a/net/oic/include/oic/oc_helpers.h b/net/oic/include/oic/oc_helpers.h
index 4855f94..24c5f0c 100644
--- a/net/oic/include/oic/oc_helpers.h
+++ b/net/oic/include/oic/oc_helpers.h
@@ -17,8 +17,6 @@
#ifndef OC_HELPERS_H
#define OC_HELPERS_H
-#include "../../src/util/oc_list.h"
-#include "../../src/util/oc_mmem.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/messaging/coap/observe.h
----------------------------------------------------------------------
diff --git a/net/oic/src/messaging/coap/observe.h b/net/oic/src/messaging/coap/observe.h
index a913745..ae63bf1 100644
--- a/net/oic/src/messaging/coap/observe.h
+++ b/net/oic/src/messaging/coap/observe.h
@@ -36,7 +36,6 @@
#include "coap.h"
#include "transactions.h"
-#include "../../util/oc_list.h"
#ifdef __cplusplus
extern "C" {
@@ -63,7 +62,6 @@ typedef struct coap_observer {
uint8_t retrans_counter;
} coap_observer_t;
-oc_list_t coap_get_observers(void);
void coap_remove_observer(coap_observer_t *o);
int coap_remove_observer_by_client(oc_endpoint_t *endpoint);
int coap_remove_observer_by_token(oc_endpoint_t *endpoint, uint8_t *token,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/messaging/coap/oc_coap.h
----------------------------------------------------------------------
diff --git a/net/oic/src/messaging/coap/oc_coap.h b/net/oic/src/messaging/coap/oc_coap.h
index cddf46f..dcc0352 100644
--- a/net/oic/src/messaging/coap/oc_coap.h
+++ b/net/oic/src/messaging/coap/oc_coap.h
@@ -18,7 +18,6 @@
#define OC_COAP_H
#include "separate.h"
-#include "../../util/oc_list.h"
#ifdef __cplusplus
extern "C" {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/messaging/coap/transactions.c
----------------------------------------------------------------------
diff --git a/net/oic/src/messaging/coap/transactions.c b/net/oic/src/messaging/coap/transactions.c
index 662ca22..42ca498 100644
--- a/net/oic/src/messaging/coap/transactions.c
+++ b/net/oic/src/messaging/coap/transactions.c
@@ -39,7 +39,6 @@
#include "transactions.h"
#include "observe.h"
#include "oc_buffer.h"
-#include "util/oc_list.h"
#ifdef OC_CLIENT
#include "oc_client_state.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/port/mynewt/config.h
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/config.h b/net/oic/src/port/mynewt/config.h
index 171625f..c8fdb06 100644
--- a/net/oic/src/port/mynewt/config.h
+++ b/net/oic/src/port/mynewt/config.h
@@ -36,11 +36,6 @@ typedef os_time_t oc_clock_time_t;
#define OC_CLK_FMT "%lu"
#endif
-/* Memory pool sizes */
-#define OC_BYTES_POOL_SIZE (2048)
-#define OC_INTS_POOL_SIZE (16)
-#define OC_DOUBLES_POOL_SIZE (16)
-
/* Server-side parameters */
/* Maximum number of server resources */
#define MAX_APP_RESOURCES MYNEWT_VAL(OC_APP_RESOURCES)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/util/oc_list.c
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_list.c b/net/oic/src/util/oc_list.c
deleted file mode 100644
index 429f411..0000000
--- a/net/oic/src/util/oc_list.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 2004, Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- * Author: Adam Dunkels <ad...@sics.se>
- *
- */
-
-#include "oc_list.h"
-
-#define NULL 0
-
-struct list
-{
- struct list *next;
-};
-
-/*---------------------------------------------------------------------------*/
-/**
- * Initialize a list.
- *
- * This function initalizes a list. The list will be empty after this
- * function has been called.
- *
- * \param list The list to be initialized.
- */
-void
-oc_list_init(oc_list_t list)
-{
- *list = NULL;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Get a pointer to the first element of a list.
- *
- * This function returns a pointer to the first element of the
- * list. The element will \b not be removed from the list.
- *
- * \param list The list.
- * \return A pointer to the first element on the list.
- *
- * \sa oc_list_tail()
- */
-void *
-oc_list_head(oc_list_t list)
-{
- return *list;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Duplicate a list.
- *
- * This function duplicates a list by copying the list reference, but
- * not the elements.
- *
- * \note This function does \b not copy the elements of the list, but
- * merely duplicates the pointer to the first element of the list.
- *
- * \param dest The destination list.
- * \param src The source list.
- */
-void
-oc_list_copy(oc_list_t dest, oc_list_t src)
-{
- *dest = *src;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Get the tail of a list.
- *
- * This function returns a pointer to the elements following the first
- * element of a list. No elements are removed by this function.
- *
- * \param list The list
- * \return A pointer to the element after the first element on the list.
- *
- * \sa oc_list_head()
- */
-void *
-oc_list_tail(oc_list_t list)
-{
- struct list *l;
-
- if (*list == NULL) {
- return NULL;
- }
-
- for (l = *list; l->next != NULL; l = l->next)
- ;
-
- return l;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Add an item at the end of a list.
- *
- * This function adds an item to the end of the list.
- *
- * \param list The list.
- * \param item A pointer to the item to be added.
- *
- * \sa oc_list_push()
- *
- */
-void
-oc_list_add(oc_list_t list, void *item)
-{
- struct list *l;
-
- /* Make sure not to add the same element twice */
- oc_list_remove(list, item);
-
- ((struct list *)item)->next = NULL;
-
- l = oc_list_tail(list);
-
- if (l == NULL) {
- *list = item;
- } else {
- l->next = item;
- }
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Add an item to the start of the list.
- */
-void
-oc_list_push(oc_list_t list, void *item)
-{
- /* Make sure not to add the same element twice */
- oc_list_remove(list, item);
-
- ((struct list *)item)->next = *list;
- *list = item;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Remove the last object on the list.
- *
- * This function removes the last object on the list and returns it.
- *
- * \param list The list
- * \return The removed object
- *
- */
-void *
-oc_list_chop(oc_list_t list)
-{
- struct list *l, *r;
-
- if (*list == NULL) {
- return NULL;
- }
- if (((struct list *)*list)->next == NULL) {
- l = *list;
- *list = NULL;
- return l;
- }
-
- for (l = *list; l->next->next != NULL; l = l->next)
- ;
-
- r = l->next;
- l->next = NULL;
-
- return r;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Remove the first object on a list.
- *
- * This function removes the first object on the list and returns a
- * pointer to it.
- *
- * \param list The list.
- * \return Pointer to the removed element of list.
- */
-/*---------------------------------------------------------------------------*/
-void *
-oc_list_pop(oc_list_t list)
-{
- struct list *l;
- l = *list;
- if (*list != NULL) {
- *list = ((struct list *)*list)->next;
- }
-
- return l;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Remove a specific element from a list.
- *
- * This function removes a specified element from the list.
- *
- * \param list The list.
- * \param item The item that is to be removed from the list.
- *
- */
-/*---------------------------------------------------------------------------*/
-void
-oc_list_remove(oc_list_t list, void *item)
-{
- struct list *l, *r;
-
- if (*list == NULL) {
- return;
- }
-
- r = NULL;
- for (l = *list; l != NULL; l = l->next) {
- if (l == item) {
- if (r == NULL) {
- /* First on list */
- *list = l->next;
- } else {
- /* Not first on list */
- r->next = l->next;
- }
- l->next = NULL;
- return;
- }
- r = l;
- }
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Get the length of a list.
- *
- * This function counts the number of elements on a specified list.
- *
- * \param list The list.
- * \return The length of the list.
- */
-/*---------------------------------------------------------------------------*/
-int
-oc_list_length(oc_list_t list)
-{
- struct list *l;
- int n = 0;
-
- for (l = *list; l != NULL; l = l->next) {
- ++n;
- }
-
- return n;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * \brief Insert an item after a specified item on the list
- * \param list The list
- * \param previtem The item after which the new item should be inserted
- * \param newitem The new item that is to be inserted
- * \author Adam Dunkels
- *
- * This function inserts an item right after a specified
- * item on the list. This function is useful when using
- * the list module to ordered lists.
- *
- * If previtem is NULL, the new item is placed at the
- * start of the list.
- *
- */
-void
-oc_list_insert(oc_list_t list, void *previtem, void *newitem)
-{
- if (previtem == NULL) {
- oc_list_push(list, newitem);
- } else {
-
- ((struct list *)newitem)->next = ((struct list *)previtem)->next;
- ((struct list *)previtem)->next = newitem;
- }
-}
-/*---------------------------------------------------------------------------*/
-/**
- * \brief Get the next item following this item
- * \param item A list item
- * \returns A next item on the list
- *
- * This function takes a list item and returns the next
- * item on the list, or NULL if there are no more items on
- * the list. This function is used when iterating through
- * lists.
- */
-void *
-oc_list_item_next(void *item)
-{
- return item == NULL ? NULL : ((struct list *)item)->next;
-}
-/*---------------------------------------------------------------------------*/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/util/oc_list.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_list.h b/net/oic/src/util/oc_list.h
deleted file mode 100644
index c0f5db8..0000000
--- a/net/oic/src/util/oc_list.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2004, Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- * Author: Adam Dunkels <ad...@sics.se>
- *
- */
-
-/**
- * \defgroup list Linked list library
- *
- * The linked list library provides a set of functions for
- * manipulating linked lists.
- *
- * A linked list is made up of elements where the first element \b
- * must be a pointer. This pointer is used by the linked list library
- * to form lists of the elements.
- *
- * Lists are declared with the LIST() macro. The declaration specifies
- * the name of the list that later is used with all list functions.
- *
- * Lists can be manipulated by inserting or removing elements from
- * either sides of the list (list_push(), list_add(), list_pop(),
- * list_chop()). A specified element can also be removed from inside a
- * list with list_remove(). The head and tail of a list can be
- * extracted using list_head() and list_tail(), respectively.
- *
- */
-
-#ifndef OC_LIST_H
-#define OC_LIST_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define OC_LIST_CONCAT2(s1, s2) s1##s2
-#define OC_LIST_CONCAT(s1, s2) OC_LIST_CONCAT2(s1, s2)
-
-/**
- * Declare a linked list.
- *
- * This macro declares a linked list with the specified \c type. The
- * type \b must be a structure (\c struct) with its first element
- * being a pointer. This pointer is used by the linked list library to
- * form the linked lists.
- *
- * The list variable is declared as static to make it easy to use in a
- * single C module without unnecessarily exporting the name to other
- * modules.
- *
- * \param name The name of the list.
- */
-#define OC_LIST(name) \
- static void *OC_LIST_CONCAT(name, _list) = NULL; \
- static oc_list_t name = (oc_list_t)&OC_LIST_CONCAT(name, _list)
-
-/**
- * Declare a linked list inside a structure declaraction.
- *
- * This macro declares a linked list with the specified \c type. The
- * type \b must be a structure (\c struct) with its first element
- * being a pointer. This pointer is used by the linked list library to
- * form the linked lists.
- *
- * Internally, the list is defined as two items: the list itself and a
- * pointer to the list. The pointer has the name of the parameter to
- * the macro and the name of the list is a concatenation of the name
- * and the suffix "_list". The pointer must point to the list for the
- * list to work. Thus the list must be initialized before using.
- *
- * The list is initialized with the LIST_STRUCT_INIT() macro.
- *
- * \param name The name of the list.
- */
-#define OC_LIST_STRUCT(name) \
- void *OC_LIST_CONCAT(name, _list); \
- oc_list_t name
-
-/**
- * Initialize a linked list that is part of a structure.
- *
- * This macro sets up the internal pointers in a list that has been
- * defined as part of a struct. This macro must be called before using
- * the list.
- *
- * \param struct_ptr A pointer to the struct
- * \param name The name of the list.
- */
-#define OC_LIST_STRUCT_INIT(struct_ptr, name) \
- do { \
- (struct_ptr)->name = &((struct_ptr)->OC_LIST_CONCAT(name, _list)); \
- (struct_ptr)->OC_LIST_CONCAT(name, _list) = NULL; \
- oc_list_init((struct_ptr)->name); \
- } while (0)
-
-/**
- * The linked list type.
- *
- */
-typedef void **oc_list_t;
-
-void oc_list_init(oc_list_t list);
-void *oc_list_head(oc_list_t list);
-void *oc_list_tail(oc_list_t list);
-void *oc_list_pop(oc_list_t list);
-void oc_list_push(oc_list_t list, void *item);
-
-void *oc_list_chop(oc_list_t list);
-
-void oc_list_add(oc_list_t list, void *item);
-void oc_list_remove(oc_list_t list, void *item);
-
-int oc_list_length(oc_list_t list);
-
-void oc_list_copy(oc_list_t dest, oc_list_t src);
-
-void oc_list_insert(oc_list_t list, void *previtem, void *newitem);
-
-void *oc_list_item_next(void *item);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OC_LIST_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/util/oc_mmem.c
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_mmem.c b/net/oic/src/util/oc_mmem.c
deleted file mode 100644
index 8a129c6..0000000
--- a/net/oic/src/util/oc_mmem.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- *
- * Copyright (c) 2005, Swedish Institute of Computer Science
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- */
-
-#include "oc_mmem.h"
-#include "config.h"
-#include "oc_list.h"
-#include "port/oc_log.h"
-#include <stdint.h>
-#include <string.h>
-
-#if !defined(OC_BYTES_POOL_SIZE) || !defined(OC_INTS_POOL_SIZE) || \
- !defined(OC_DOUBLES_POOL_SIZE)
-#error "Please define byte, int, double pool sizes in config.h"
-#endif /* ...POOL_SIZE */
-
-static double doubles[OC_DOUBLES_POOL_SIZE];
-static int64_t ints[OC_INTS_POOL_SIZE];
-static unsigned char bytes[OC_BYTES_POOL_SIZE];
-static unsigned int avail_bytes, avail_ints, avail_doubles;
-
-OC_LIST(bytes_list);
-OC_LIST(ints_list);
-OC_LIST(doubles_list);
-
-/*---------------------------------------------------------------------------*/
-int
-oc_mmem_alloc(struct oc_mmem *m, unsigned int size, pool pool_type)
-{
- switch (pool_type) {
- case BYTE_POOL:
- if (avail_bytes < size) {
- return 0;
- }
- oc_list_add(bytes_list, m);
- m->ptr = &bytes[OC_BYTES_POOL_SIZE - avail_bytes];
- m->size = size;
- avail_bytes -= size;
- break;
- case INT_POOL:
- if (avail_ints < size) {
- return 0;
- }
- oc_list_add(ints_list, m);
- m->ptr = &ints[OC_INTS_POOL_SIZE - avail_ints];
- m->size = size;
- avail_ints -= size;
- break;
- case DOUBLE_POOL:
- if (avail_doubles < size) {
- return 0;
- }
- oc_list_add(doubles_list, m);
- m->ptr = &doubles[OC_DOUBLES_POOL_SIZE - avail_doubles];
- m->size = size;
- avail_doubles -= size;
- break;
- default:
- break;
- }
- return 1;
-}
-
-void
-oc_mmem_free(struct oc_mmem *m, pool pool_type)
-{
- struct oc_mmem *n;
-
- if (m->next != NULL) {
- switch (pool_type) {
- case BYTE_POOL:
- memmove(m->ptr, m->next->ptr, &bytes[OC_BYTES_POOL_SIZE - avail_bytes] -
- (unsigned char *)m->next->ptr);
- break;
- case INT_POOL:
- memmove(m->ptr, m->next->ptr,
- &ints[OC_INTS_POOL_SIZE - avail_ints] - (int64_t *)m->next->ptr);
- break;
- case DOUBLE_POOL:
- memmove(m->ptr, m->next->ptr,
- &doubles[OC_DOUBLES_POOL_SIZE - avail_doubles] -
- (double *)m->next->ptr);
- break;
- default:
- return;
- break;
- }
- for (n = m->next; n != NULL; n = n->next) {
- n->ptr = (void *)((char *)n->ptr - m->size);
- }
- }
-
- switch (pool_type) {
- case BYTE_POOL:
- avail_bytes += m->size;
- oc_list_remove(bytes_list, m);
- break;
- case INT_POOL:
- avail_ints += m->size;
- oc_list_remove(ints_list, m);
- break;
- case DOUBLE_POOL:
- avail_doubles += m->size;
- oc_list_remove(doubles_list, m);
- break;
- }
-}
-
-void
-oc_mmem_init(void)
-{
- static int inited = 0;
- if (inited) {
- return;
- }
- oc_list_init(bytes_list);
- oc_list_init(ints_list);
- oc_list_init(doubles_list);
- avail_bytes = OC_BYTES_POOL_SIZE;
- avail_ints = OC_INTS_POOL_SIZE;
- avail_doubles = OC_DOUBLES_POOL_SIZE;
- inited = 1;
-}
-/*---------------------------------------------------------------------------*/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/049222d3/net/oic/src/util/oc_mmem.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_mmem.h b/net/oic/src/util/oc_mmem.h
deleted file mode 100644
index bcd170f..0000000
--- a/net/oic/src/util/oc_mmem.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- *
- * Copyright (c) 2005, Swedish Institute of Computer Science
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- */
-
-#ifndef OC_MMEM_H
-#define OC_MMEM_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define OC_MMEM_PTR(m) (struct oc_mmem *)(m)->ptr
-
-struct oc_mmem
-{
- struct oc_mmem *next;
- unsigned int size;
- void *ptr;
-};
-
-typedef enum { BYTE_POOL, INT_POOL, DOUBLE_POOL } pool;
-
-int oc_mmem_alloc(struct oc_mmem *m, unsigned int size, pool pool_type);
-void oc_mmem_free(struct oc_mmem *, pool pool_type);
-void oc_mmem_init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OC_MMEM_H */