shrddr / array Goto Github PK
View Code? Open in Web Editor NEWsafe array (range checking etc)
safe array (range checking etc)
MSVS2013 debug configuration:
The test program with this code hangs after reaching the end of scope:
Array a(2);
a.set(0, 42);
a.set(1, 69);
Array b(a);
MSVS2013 release configuration:
triggered a breakpoint at free.c
Ubuntu:
*** Error in `./test': double free or corruption (fasttop): 0x000000000188d010 ***
What happens:
Default copy constructor sets b.myData = a.myData
.
Destructor of a
deletes the myData array.
Then, destructor of b
is called, tries to delete the same array and never succeeds.
Solution:
Create a custom copy constructor
g++ Array.cpp Test.cpp
In file included from Array.cpp:1:0:
Array.h:5:2: error: ‘size_t’ does not name a type
Array a(2);
a.set(0, 42);
a.set(1, 69);
Array c(1);
c = a;
MSVS2013 debug:
Debug Assertion Failed!
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Line: 52
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
MSVS2013 release:
breakpoint at free.c
Ubuntu:
works fine
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.