2 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <sys/smack.h>
25 #define DEFINE_SMARTPTR(func, type, name) \
26 struct deleter_##func { \
27 void operator()(type* p) {\
32 typedef std::unique_ptr<type, deleter_##func> name;
34 // Custom freeing functions
36 void closePtr(int *fd);
38 // Defining specializations of unique_ptr
40 DEFINE_SMARTPTR(free, char, CStringPtr);
41 DEFINE_SMARTPTR(g_free, gchar, GStringPtr);
42 DEFINE_SMARTPTR(closePtr, int, FdUniquePtr);
43 DEFINE_SMARTPTR(smack_accesses_free, smack_accesses, SmackAccessesPtr);
44 DEFINE_SMARTPTR(closedir, DIR, DirPtr);
45 DEFINE_SMARTPTR(globfree, glob_t, GlobPtr);
49 typedef FdUniquePtr SockUniquePtr;
50 typedef CStringPtr SmackLabelPtr;
51 typedef CStringPtr CookieUniquePtr;