summaryrefslogtreecommitdiff
path: root/src/bindings/cxx/eina_cxx/eina_deleter.hh
blob: 7831dfd8eee51dfe6a032e0d4069a56a7654ea7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef EINA_DELETERS_HH_
#define EINA_DELETERS_HH_

#include <eina_workarounds.hh>

#include <Eina.h>

namespace efl { namespace eina {

struct malloc_deleter
{
  template <typename T>
  void operator()(T* object) const
  {
    object->~T();
    free(object);
  }
  void operator()(Eina_Future*) const
  {
    // workaround until we substitute Efl_Future with Eina_Future
  }
  void operator()(Eina_Binbuf* /*object*/) const
  {
    // how to free binbuf?
  }
  void operator()(Eina_Promise*) const
  {
    // workaround until we manually handle efl_loop_promise_new
  }
};

template <typename T>
using unique_malloc_ptr = std::unique_ptr<T, malloc_deleter>;
    
} }

#endif