Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Author: Jeff Thompson |
| 3 | * |
| 4 | * BSD license, See the LICENSE file for more information. |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Based on HAVE_MEMCPY and HAVE_MEMSET in config.h, use the library version or a local implementation of memcpy and memset. |
| 9 | */ |
| 10 | |
| 11 | #ifndef NDN_MEMORY_H |
| 12 | #define NDN_MEMORY_H |
| 13 | |
| 14 | #include "../../config.h" |
| 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
| 20 | #if HAVE_MEMCPY |
| 21 | #include <memory.h> |
| 22 | /** |
| 23 | * Use the library version of memcpy. |
| 24 | */ |
| 25 | static inline void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len) { memcpy(dest, src, len); } |
| 26 | #else |
| 27 | /** |
| 28 | * Use a local implementation of memcpy instead of the library version. |
| 29 | */ |
| 30 | void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len); |
| 31 | #endif |
| 32 | |
| 33 | #if HAVE_MEMSET |
| 34 | #include <memory.h> |
| 35 | /** |
| 36 | * Use the library version of memset. |
| 37 | */ |
| 38 | static inline void ndn_memset(unsigned char *dest, int val, unsigned int len) { memset(dest, val, len); } |
| 39 | #else |
| 40 | /** |
| 41 | * Use a local implementation of memset instead of the library version. |
| 42 | */ |
| 43 | void ndn_memset(unsigned char *dest, int val, unsigned int len); |
| 44 | #endif |
| 45 | |
| 46 | #ifdef __cplusplus |
| 47 | } |
| 48 | #endif |
| 49 | |
| 50 | #endif |
| 51 | |