From ac0688a8d79049cca45de2b6a2565c176e85200e Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 14 Mar 2011 12:07:08 -0600 Subject: [PATCH] Fix warnings in memory_leak_test --- samples/memory_leak_test.cpp | 100 +++++++++++++++++------------------ 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/samples/memory_leak_test.cpp b/samples/memory_leak_test.cpp index 4565609..bbd8a5f 100644 --- a/samples/memory_leak_test.cpp +++ b/samples/memory_leak_test.cpp @@ -11,49 +11,49 @@ using namespace chaiscript; std::string get_next_command() { #ifdef READLINE_AVAILABLE - char *input_raw; - input_raw = readline("eval> "); - add_history(input_raw); - return std::string(input_raw); + char *input_raw; + input_raw = readline("eval> "); + add_history(input_raw); + return std::string(input_raw); #else - std::string retval; - std::cout << "eval> "; - std::getline(std::cin, retval); - return retval; + std::string retval; + std::cout << "eval> "; + std::getline(std::cin, retval); + return retval; #endif } void fuction(void) { - // do nothing + // do nothing } class test { - ChaiScript chai; - ChaiScript::State backupState; -public: - test() - { - backupState = chai.get_state(); - } - ~test(){} + ChaiScript chai; + ChaiScript::State backupState; + public: + test() + { + backupState = chai.get_state(); + } + ~test(){} - void ResetState() - { - chai.set_state(backupState); - chai.add(fun(&fuction),"Whatever()"); - } - void RunFile(std::string sFile) - { - chaiscript::Boxed_Value val; - try { - chaiscript::Boxed_Value val = chai.eval_file(sFile); - } - catch (std::exception &e) { - std::cout << e.what() << std::endl; - } - } + void ResetState() + { + chai.set_state(backupState); + chai.add(fun(&fuction),"Whatever()"); + } + + void RunFile(std::string sFile) + { + try { + chaiscript::Boxed_Value val = chai.eval_file(sFile); + } + catch (std::exception &e) { + std::cout << e.what() << std::endl; + } + } }; @@ -61,28 +61,28 @@ public: int main(int /*argc*/, char * /*argv*/[]) { - test myChai; + test myChai; - std::string command = ""; + std::string command = ""; - // - // this loop increases memoryusage, if RunFile is not called (just hittin enter) - // as soon RunFile gets called, memory will be freed. - // - // scenario1 - RunFile gets called every Loop: memoryusage does not change - // scenario2 - RunFile gets never called (just hitting enter): memoryusage increases every loop - // scenario3 - RunFile gets in changing intervals: memoryusage goes up and down, but never as - // low as in case 1 scenario3 : + // + // this loop increases memoryusage, if RunFile is not called (just hittin enter) + // as soon RunFile gets called, memory will be freed. + // + // scenario1 - RunFile gets called every Loop: memoryusage does not change + // scenario2 - RunFile gets never called (just hitting enter): memoryusage increases every loop + // scenario3 - RunFile gets in changing intervals: memoryusage goes up and down, but never as + // low as in case 1 scenario3 : - while(command != "quit") - { - for(int i = 1; i < 200; i++) - myChai.ResetState(); + while(command != "quit") + { + for(int i = 1; i < 200; i++) + myChai.ResetState(); - if(command == "runfile") - myChai.RunFile("Test.chai"); + if(command == "runfile") + myChai.RunFile("Test.chai"); - command = get_next_command(); - } + command = get_next_command(); + } }