nim_duilib/base/memory/deleter.h
jiajia_deng 4933d1f2bc Remove dependency on shared
Signed-off-by: jiajia_deng <2894220@gmail.com>
2019-09-20 16:27:58 +08:00

33 lines
698 B
C++

// a implementation of scoped handle which ensures the safe use of stardard handles
#ifndef BASE_MEMORY_SCOPED_STD_HANDLE_H_
#define BASE_MEMORY_SCOPED_STD_HANDLE_H_
#include <stdio.h>
#include "base/base_config.h"
#include "base/base_export.h"
#include "base/base_types.h"
namespace nbase
{
// This class wraps the c library function free() in a class that can be
// passed as a template argument to scoped_ptr_malloc below.
class BASE_EXPORT DeleterFree {
public:
inline void operator()(void* x) const {
free(x);
}
};
class BASE_EXPORT DeleterFileClose {
public:
inline void operator()(FILE * x) const {
fclose(x);
}
};
} // namespace
#endif // BASE_MEMORY_SCOPED_STD_HANDLE_H_