-
-
Save snoopspy/e3e197157c478c6fea4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstring> | |
#include <iostream> | |
char buf[256]; | |
size_t idx = 0; | |
void *malloc(size_t size) { | |
void* res = &buf[idx]; | |
memset(res, 0xFF, size); | |
idx += size; | |
return res; | |
} | |
void free(void* ptr) { | |
(void)ptr; | |
} | |
int main() { | |
{ | |
int* i = new int; | |
std::cout << *i << std::endl; | |
delete i; | |
} | |
{ | |
int* i = new int(); | |
std::cout << *i << std::endl; | |
delete i; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[environment]
os : 14.04.1-Ubuntu 64 bit
compiler : g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
build : g++ -std=c++11 test.cpp
[result]
-1
0