Skip to Main Content
Software Essentials
book

Software Essentials

by Adair Dingle
July 2014
Intermediate to advanced content levelIntermediate to advanced
436 pages
12h 27m
English
Chapman and Hall/CRC
Content preview from Software Essentials
Functionality 69
address, and stores the value of the program counter at the point of call (so
that the function return can execute correctly). Functions may have local
data: the compiler lays out memory for such data. Statement #1 in each
function in Example 3.7 illustrates the allocation of local data (the pointer
db) as does the passed parameter n in Example 3.14. e program counter
and local data are laid out in a stack frame associated with the function.
Example 3.7: Premature vs. Timely Return: C++
//return may be executed before resource released => memory leak
void misManagedResources()
{ int* db = new int[100]; //#1 resource (memory) allocated
if (done()) return; //#2 avoid work if not needed
//resource not released ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Software Architect’s Handbook

Software Architect’s Handbook

Joseph Ingeno
Economics-Driven Software Architecture

Economics-Driven Software Architecture

Ivan Mistrik, Rami Bahsoon, Rick Kazman, Yuanyuan Zhang
Software Architect Bootcamp

Software Architect Bootcamp

Raphael Malveau, Ph.D. Thomas J. Mowbray

Publisher Resources

ISBN: 9781439841204