From 4b953bf080dcb37bd60e69194f52dc45e38bb4db Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 24 Aug 2014 14:59:54 +0200 Subject: [PATCH] add malloc-new --- .gitignore | 1 + CMakeLists.txt | 1 + malloc-new.cpp | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 malloc-new.cpp diff --git a/.gitignore b/.gitignore index 9a0f16a..b8b9774 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ return-type-deduction division poly ohai-const-strings +malloc-new diff --git a/CMakeLists.txt b/CMakeLists.txt index aa7936b..6733973 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ add_executable(bad_alloc bad_alloc.cpp) add_executable(rtti rtti.cpp) add_executable(poly poly.cpp) add_executable(division division.cpp) +add_executable(malloc-new malloc-new.cpp) add_executable(ohai-const-strings ohai-const-strings.cpp) add_executable(future future.cpp) diff --git a/malloc-new.cpp b/malloc-new.cpp new file mode 100644 index 0000000..068f84e --- /dev/null +++ b/malloc-new.cpp @@ -0,0 +1,15 @@ +#include +#include + +using std::cout; +using std::endl; + +int main(void) { + char** foo = new char*[100]; + delete[] foo; + + char** bar = (char**) malloc(100*sizeof(char*)); + assert(bar != NULL); + // for valgrind to find: + // free(bar); +}