Skip to content

Commit 0ad19cb

Browse files
authored
Merge pull request #25 from kimkulling/fix_linkage
Enable linkage
2 parents 508da92 + ecdb2f6 commit 0ad19cb

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

include/cppcore/Memory/MemUtils.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323
#pragma once
2424

2525
#include <cppcore/CPPCoreCommon.h>
26+
#include <string.h>
27+
#include <cinttypes>
2628

2729
namespace cppcore {
2830

@@ -42,15 +44,27 @@ inline size_t align(size_t n) {
4244
class DLL_CPPCORE_EXPORT MemUtils {
4345
public:
4446
/// @brief Will clear the given buffer with zero.
45-
/// @param buffer [inout] The buffer to clear.
47+
/// @param[inout] buffer The buffer to clear.
4648
static void clearMemory(void *buffer, size_t size);
4749

50+
/// @brief Will return true, if the pointer fits into the alignment.
51+
/// @param[in] ptr The pointer to check.
52+
/// @param[in] align The alignment to check for.
53+
/// @return true if aligned, false if not.
4854
static bool isAligned(const void *ptr, size_t align);
4955

56+
/// @brief Will align the given pointer.
57+
/// @param[in] ptr The pointer to align.
58+
/// @param[in] extra Space for headers / meta information.
59+
/// @param[in] align The alignment to check for.
60+
/// @return The aligned pointer.
5061
static const void *alignPtr(void *ptr, size_t extra, size_t align);
5162

52-
MemUtils() = delete;
53-
~MemUtils() = delete;
63+
/// @brief The default class constructor.
64+
MemUtils() = default;
65+
66+
/// @brief The class destructor.
67+
~MemUtils() = default;
5468
};
5569

5670
inline bool MemUtils::isAligned(const void *ptr, size_t align) {
@@ -64,6 +78,9 @@ inline bool MemUtils::isAligned(const void *ptr, size_t align) {
6478
}
6579

6680
inline const void *MemUtils::alignPtr(void *ptr, size_t extra, size_t align) {
81+
if (align == 0) {
82+
return nullptr;
83+
}
6784
union {
6885
const void *mPtr;
6986
uintptr_t mAddr;

0 commit comments

Comments
 (0)