ndn_memory.h
1 
21 /*
22  * Based on NDN_CPP_HAVE_MEMCMP, NDN_CPP_HAVE_MEMCPY and NDN_CPP_HAVE_MEMSET in
23  * ndn-cpp-config.h, use the library version or a local implementation of
24  * memcmp, memcpy and memset.
25  */
26 
27 #ifndef NDN_MEMORY_H
28 #define NDN_MEMORY_H
29 
30 #include <ndn-cpp/c/common.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #if NDN_CPP_HAVE_MEMCMP
37 
38 #if NDN_CPP_HAVE_MEMORY_H
39 #include <memory.h>
40 #else
41 #include <string.h>
42 #endif
43 
46 static __inline int ndn_memcmp(const uint8_t *buf1, const uint8_t *buf2, size_t len) { return memcmp(buf1, buf2, len); }
47 #else
48 
51 int ndn_memcmp(const uint8_t *buf1, const uint8_t *buf2, size_t len);
52 #endif
53 
54 #if NDN_CPP_HAVE_MEMCPY
55 
56 #if NDN_CPP_HAVE_MEMORY_H
57 #include <memory.h>
58 #else
59 #include <string.h>
60 #endif
61 
64 static __inline void ndn_memcpy(uint8_t *dest, const uint8_t *src, size_t len) { memcpy(dest, src, len); }
65 #else
66 
69 void ndn_memcpy(uint8_t *dest, const uint8_t *src, size_t len);
70 #endif
71 
72 #if NDN_CPP_HAVE_MEMSET
73 
74 #if NDN_CPP_HAVE_MEMORY_H
75 #include <memory.h>
76 #else
77 #include <string.h>
78 #endif
79 
82 static __inline void ndn_memset(uint8_t *dest, int val, size_t len) { memset(dest, val, len); }
83 #else
84 
87 void ndn_memset(uint8_t *dest, int val, size_t len);
88 #endif
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif
95