CKM:Add compilation flag for MDPP
[platform/core/test/security-tests.git] / tests / common / memory.h
1 #ifndef MEMORY_H
2 #define MEMORY_H
3
4 #include <memory>
5 #include <sys/smack.h>
6
7 #define DEFINE_SMARTPTR(func, type, name) \
8     struct deleter_##func { \
9         void operator()(type* p) {\
10             func(p); \
11         } \
12     }; \
13      \
14     typedef std::unique_ptr<type, deleter_##func> name;
15
16 // Custom freeing functions
17
18 void closePtr(int *fd);
19
20 // Defining specializations of unique_ptr
21
22 DEFINE_SMARTPTR(free, char, CStringPtr);
23 DEFINE_SMARTPTR(closePtr, int, FdUniquePtr);
24 DEFINE_SMARTPTR(smack_accesses_free, smack_accesses, SmackAccessesPtr);
25
26 // Custom typedefs
27
28 typedef FdUniquePtr SockUniquePtr;
29 typedef CStringPtr SmackLabelPtr;
30 typedef CStringPtr CookieUniquePtr;
31
32 #endif // MEMORY_H