/* Fornux C Leak Detector - Generated Code. Copyright (C) 2017 Phil Bouchard This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ struct Document; namespace boost { template <> void proxy(boost::node_proxy const& __y, Document const& o); template <> struct create { template boost::node >* operator()(node_proxy const& __y, size_t s, Args const&... args); }; template <> struct construct { Document operator()(node_proxy const& __y, char const* n); Document operator()(node_proxy const& __y, char const* n, Document const& o); }; } static boost::node_proxy __x; #include #include #include extern "C" int function1(boost::node_proxy& __y, int argument) { boost::node_proxy __x; boost::root_ptr > p = boost::root_ptr(__x, "p", boost::create()(__x, (sizeof(int)) / sizeof(decltype(p)::value_type::value_type))); int k[10]; cld::printf("%s\n", __FUNCTION__); p.reset(nullptr); return cld::proxy(__y, argument); } struct Document { boost::node_proxy const& __x; int i = boost::construct()(__x, "i"); boost::root_ptr > head = boost::construct > >()(__x, "head"); boost::root_ptr > tail = boost::construct > >()(__x, "tail"); int foo(boost::node_proxy& __y, int argument) { boost::node_proxy __x; cld::printf("%s\n", __FUNCTION__); return cld::proxy(__y, argument); } Document() : __x(*static_cast(0)) { throw std::runtime_error("restricted access"); } Document(boost::node_proxy const& __y) : __x(__y) { } }; extern "C" int function2(boost::node_proxy& __y, int argument) { boost::node_proxy __x; boost::root_ptr > p = boost::root_ptr(__x, "p", boost::create()(__x, (sizeof(int)) / sizeof(decltype(p)::value_type::value_type))); int k[10]; cld::printf("%s\n", __FUNCTION__); return cld::proxy(__y, argument); } extern "C" boost::root_ptr > bar(boost::node_proxy& __y) { boost::node_proxy __x; boost::root_ptr > document = boost::root_ptr(__x, "document", boost::create()(__x, (sizeof(Document)) / sizeof(decltype(document)::value_type::value_type))); document->head = boost::root_ptrhead)::value_type>(__x, "", boost::createhead)::value_type::value_type>()(__x, (sizeof(Document)) / sizeof(decltype(document->head)::value_type::value_type))); document->head->head = boost::root_ptrhead->head)::value_type>(__x, "", boost::createhead->head)::value_type::value_type>()(__x, (sizeof(Document)) / sizeof(decltype(document->head->head)::value_type::value_type))); document->head->head->head = document; return cld::proxy(__y, document); } boost::root_ptr > text1 = boost::construct()(__x, "text1", cld::to_iterator("Is this on?")); boost::root_ptr > array1 = boost::construct()(__x, "array1", cld::to_iterator({ 1, 2, 3, 4, 5 })); extern "C" int main(boost::node_proxy& __y) { boost::node_proxy __x; typedef int (*function3_t)(boost::node_proxy& __y, int argument); function3_t function3 = boost::construct()(__x, "function3", function2); int temporary = boost::construct()(__x, "temporary", 1); boost::root_ptr > document = boost::root_ptr(__x, "document", boost::create()(__x, 10)); document = (document.emplace_resize((sizeof(Document) * 20) / sizeof(decltype(document)::value_type::value_type), __x), document); cld::printf("%i\n", 1); int result = boost::construct()(__x, "result", bar(__x)->foo(__x, temporary)); cld::printf("%i\n", 2); cld::printf("%d\n", ++document[18].i); cld::printf("%p\n", document[18].head); cld::printf("%p\n", document[18].tail); function1(__x, 1); function2(__x, 1); boost::root_ptr > text2 = boost::construct()(__x, "text2", cld::to_iterator("Is this on?")); static boost::root_ptr > array2 = boost::construct()(__x, "array2", cld::to_iterator({ 1, 2, 3, 4, 5 })); boost::root_ptr > text3 = boost::construct > >()(__x, "text3", cld::strdup(__x, text2)); cld::printf("%s\n", text2); cld::printf("The magic number is: %i\n", double(3.1416)); memcpy(text3, text2, strlen(text2)); cld::printf("text3 = %s\n", text3); memset(text3, 0, strlen(text2)); cld::printf("text3 = %s\n", text3); text3 = cld::strndup(__x, text2, 50); cld::printf("text3 = %s\n", text3); text3 = NULL; char buffer[256]; boost::root_ptr > cwd = boost::construct > >()(__x, "cwd", getcwd(buffer, sizeof(buffer))); cld::printf("cwd = %s\n", cwd); boost::root_ptr > text4 = boost::construct > >()(__x, "text4", cld::strdup(__x, cwd)); cld::printf("text4 = %s\n", text4); } namespace boost { template <> inline void proxy(boost::node_proxy const& __y, Document const& o) { cld::proxy(__y, o.i); cld::proxy(__y, o.head); cld::proxy(__y, o.tail); } template < typename... Args> inline boost::node >* create:: operator()(node_proxy const& __y, size_t s, Args const&... args) { return new boost::node >(s, __y, args...); } inline Document construct:: operator()(node_proxy const& __y, char const* n) { return Document(__y); } inline Document construct:: operator()(node_proxy const& __y, char const* n, Document const& o) { return Document(o); } }