1/* 2 * Copyright (c) 2014, The Linux Foundation. All rights reserved. 3 * Permission to use, copy, modify, and/or distribute this software for 4 * any purpose with or without fee is hereby granted, provided that the 5 * above copyright notice and this permission notice appear in all copies. 6 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 7 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 8 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 9 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 10 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 11 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 12 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 */ 14 15#ifndef _AOS_MEM_PVT_H 16#define _AOS_MEM_PVT_H 17 18#include <stdlib.h> 19#include <string.h> 20 21static inline void *__aos_mem_alloc(aos_size_t size) 22{ 23 return (malloc(size)); 24} 25 26static inline void __aos_mem_free(void *buf) 27{ 28 free(buf); 29} 30 31/* move a memory buffer */ 32static inline void 33__aos_mem_copy(void *dst, void *src, aos_size_t size) 34{ 35 memcpy(dst, src, size); 36} 37 38/* set a memory buffer */ 39static inline void 40__aos_mem_set(void *buf, a_uint8_t b, aos_size_t size) 41{ 42 memset(buf, b, size); 43} 44 45/* zero a memory buffer */ 46static inline void 47__aos_mem_zero(void *buf, aos_size_t size) 48{ 49 memset(buf, 0, size); 50} 51 52/* compare two memory buffers */ 53static inline int 54__aos_mem_cmp(void *buf1, void *buf2, aos_size_t size) 55{ 56 return (memcmp(buf1, buf2, size) == 0) ? 0 : 1; 57} 58 59 60 61#endif /*_AOS_MEM_PVT_H*/ 62