summaryrefslogtreecommitdiff
path: root/src/tests/eina_cxx
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-03-10 12:25:42 +0900
committerCedric BAIL <cedric.bail@samsung.com>2014-03-10 12:35:00 +0900
commit2ab6aac74d75bc07a6ed77993e7b82b2f1d4de55 (patch)
tree94f981a5aa6bbcbcaac2770913f561647d4e7cab /src/tests/eina_cxx
parent416376e03c8ac2f5fa990956fbebcada5704c666 (diff)
eina-cxx: Added malloc_clone_allocator to use with POD's when wrapping Eina C structures
Summary: Added efl::eina::malloc_clone_allocator to be used with ptr_* data structures for wrapping structures allocated by EFL in C. This allows for example: void foo(Eina_List* l) { efl::eina::ptr_list<int, efl::eina::malloc_clone_allocator> list(l); } If the standard efl::eina::heap_no_clone_allocator is used, the deallocation code uses C++ delete operator, which causes undefined behavior because the allocation was originally done with malloc. Reviewers: cedric CC: savio, cedric Differential Revision: https://phab.enlightenment.org/D614
Diffstat (limited to 'src/tests/eina_cxx')
-rw-r--r--src/tests/eina_cxx/eina_cxx_test_ptrlist.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc b/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc
index dbded3ac46..d68095e45e 100644
--- a/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc
+++ b/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc
@@ -128,6 +128,19 @@ START_TEST(eina_cxx_ptrlist_insert)
128} 128}
129END_TEST 129END_TEST
130 130
131
132START_TEST(eina_cxx_ptrlist_malloc_clone_allocator)
133{
134 efl::eina::eina_init eina_init;
135
136 efl::eina::ptr_list<int, efl::eina::malloc_clone_allocator> list1;
137 list1.push_back(5);
138 list1.push_back(10);
139
140 efl::eina::ptr_list<int, efl::eina::malloc_clone_allocator> list2 = list1;
141}
142END_TEST
143
131START_TEST(eina_cxx_ptrlist_constructors) 144START_TEST(eina_cxx_ptrlist_constructors)
132{ 145{
133 efl::eina::eina_init eina_init; 146 efl::eina::eina_init eina_init;
@@ -240,4 +253,5 @@ eina_test_ptrlist(TCase* tc)
240 tcase_add_test(tc, eina_cxx_ptrlist_constructors); 253 tcase_add_test(tc, eina_cxx_ptrlist_constructors);
241 tcase_add_test(tc, eina_cxx_ptrlist_erase); 254 tcase_add_test(tc, eina_cxx_ptrlist_erase);
242 tcase_add_test(tc, eina_cxx_ptrlist_range); 255 tcase_add_test(tc, eina_cxx_ptrlist_range);
256 tcase_add_test(tc, eina_cxx_ptrlist_malloc_clone_allocator);
243} 257}