icalmem.hpp 528 B

12345678910111213141516171819
  1. #ifndef ICALMEM_HPP
  2. #define ICALMEM_HPP 1
  3. #include <memory>
  4. #include <libical/ical.h>
  5. class icalmapi_delete {
  6. public:
  7. void operator()(icalcomponent *p) { icalcomponent_free(p); }
  8. void operator()(icalproperty *p) { icalproperty_free(p); }
  9. void operator()(icaltimezone *p) { icaltimezone_free(p, true); }
  10. void operator()(char *p) { icalmemory_free_buffer(p); }
  11. };
  12. typedef std::unique_ptr<icalcomponent, icalmapi_delete> icalcomp_ptr;
  13. typedef std::unique_ptr<char[], icalmapi_delete> icalmem_ptr;
  14. #endif /* ICALMEM_HPP */