Click here to Skip to main content Click here to Skip to main
content  Tagged as  new(local) for safer and simpler code with
no need for smart-pointer template wrappers  , 25 Oct 2012 CPOL
Rate this: Please Sign up or sign in to vote. reduce bugs and
memory leaks by using new(local)   Pointers always envied
automatic cleanup that is in C++ provided only for big fat slow
statically allocated (automatic) object or their arrays stored
by value. In this article we will introduce concept of scopes
also for dynamic objects and scoped version of new/malloc to
take advantage of those scopes (I.E. associated objects/memory
will get destroyed with the scope). Plus your code will now be
smaller (and generated binary) and simpler. I got this idea
about pointers deserving automatic cleanup love too in my other
kinda lame article about new operator  struct Object :
Scope::Obj {  Scope global; // entering scope void proc() {
Scope local;     char*  text = strdup(local,"text"): // malloc
based memory have automatic clea