Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include "ndn_memory.h" |
| 7 | |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame^] | 8 | #if !HAVE_MEMCMP |
| 9 | int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len) |
| 10 | { |
| 11 | unsigned int i; |
| 12 | |
| 13 | for (i = 0; i < len; i++) { |
| 14 | if (buf1[i] > buf2[i]) |
| 15 | return 1; |
| 16 | else if (buf1[i] < buf2[i]) |
| 17 | return -1; |
| 18 | } |
| 19 | |
| 20 | return 0; |
| 21 | } |
| 22 | #else |
| 23 | int ndn_memcmp_stub_to_avoid_empty_file_warning = 0; |
| 24 | #endif |
| 25 | |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 26 | #if !HAVE_MEMCPY |
| 27 | void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len) |
| 28 | { |
| 29 | unsigned int i; |
| 30 | |
| 31 | for (i = 0; i < len; i++) |
| 32 | dest[i] = src[i]; |
| 33 | } |
Jeff Thompson | 2275e60 | 2013-06-28 22:24:47 -0700 | [diff] [blame] | 34 | #else |
| 35 | int ndn_memcpy_stub_to_avoid_empty_file_warning = 0; |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 36 | #endif |
| 37 | |
| 38 | #if !HAVE_MEMSET |
| 39 | void ndn_memset(unsigned char *dest, int val, unsigned int len) |
| 40 | { |
| 41 | unsigned int i; |
| 42 | |
| 43 | for (i = 0; i < len; i++) |
| 44 | dest[i] = (unsigned char)val; |
| 45 | } |
Jeff Thompson | 2275e60 | 2013-06-28 22:24:47 -0700 | [diff] [blame] | 46 | #else |
| 47 | int ndn_memset_stub_to_avoid_empty_file_warning = 0; |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame^] | 48 | #endif |