NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
memory_portable.h
Go to the documentation of this file.
1 
11 #ifndef SDK_BASE_memory_portable_H_
12 #define SDK_BASE_memory_portable_H_
13 
14 #include <base/inc/platform.h>
15 
16 #if defined(SDK_OS_WIN) || defined(SDK_OS_MAC) || defined(SDK_OS_ANDROID)
17 #include <memory>
18 #else
19 #include <memory>
20 #include <string.h>
21 #endif
22 
25 inline size_t SDKMemCopy(void* destination, size_t destination_size,
26  const void* source, size_t source_size)
27 {
28 #if defined(SDK_OS_WIN)
29  #if !defined(SDK_CC_BCC)
30  size_t copy_size = source_size > destination_size ? destination_size : source_size;
31  if (!copy_size)
32  return copy_size; // Nothing to copy
33  if (!::memcpy_s(destination, destination_size, source, copy_size))
34  return copy_size;
35  else
36  return 0;
37  //return ::memcpy_s(destination, destination_size, source, copy_size);
38  #else
39  size_t copy_size = source_size > destination_size ? destination_size : source_size;
40  if (!copy_size)
41  return 0; // Nothing to copy
42  if (!std::memcpy(destination, source, copy_size))
43  return 0;
44  return copy_size;
45  #endif
46 #else
47  size_t copy_size = source_size > destination_size ? destination_size : source_size;
48  if (!copy_size)
49  return 0; // Nothing to copy
50  if (!::memcpy(destination, source, copy_size))
51  return 0;
52  return copy_size;
53 #endif
54 }
55 
56 #endif // SDK_BASE_memory_portable_H_
SDKMemCopy
size_t SDKMemCopy(void *destination, size_t destination_size, const void *source, size_t source_size)
Copies a memory chunk of a specified size to a specified location.
Definition: memory_portable.h:25
platform.h
Describes the platform constants.