Unified Control-Data Flow Diagrams (UCDF) Reference
Location and Creation
of Objects
Simple types
In memory, there are three types of
data holder locations:
in static memory, on stack, and on heap.
If constructors are
involved
Static data are stored in data segments.
There could be many of them in the program.
data segment .mydata
int myVar;
myfile.cpp
int myVar;
Stack data holders are created on stack
when a function is being called, or when
a new {} block is entered. In this case,
the function, or the block "owns" the
variable.
Note, that these pictured variables are two
different ones, though the name is the same.
Both of them exist within
the scope A of myFunction(). It is shown
with two different dataholder ovals.
The external myVar can be accessed,
for example, through a pointer to it
(not shown).
myFunction()
int myVar;
{ // scope A
int myVar;
}
int myVar;
stack
Heap objects are created explicitly
with allocation code.
myFunction()
int *p2 = new int(3);
system heap
int
p2
anotherFunction()
Code passing p2
from myFunction() to
anotherFunction()
and should be deleted somewhere,
in this case, in anotherFunction().
its address
If there is a need to show constructors,
the picture becomes more complicated.
Global objects:
data segment .mydata
Obj myObj;
myfile.cpp
Obj myObj2;
Objects belonging to a function:
myFunction()
Obj myObj;
{ // scope A
Obj myVar;
}
Heap objects exists between function calls
myFunction()
int *p2 = new Obj();
system heap
Obj
p2
anotherFunction()
Code passing p2
from myFunction() to
anotherFunction()
and should be deleted somewhere
its address
class Obj
{
int iv2;
int value;
char a[3];
};
Obj::Obj(){}
C runtime startup code
executed before main()
1
Obj::Obj(&myObj);
2
Obj::Obj(&myObj2);
Pseudocode of
a constructor caller
the constructor itself
C runtime exit code
~Obj::Obj(){}
1
end
Generally, it is not necessary to show calls to constructors and destructors.
Again, diagrams are to simplify understanding, not to make it more complicated.
static, global
We can omit these details and assume that
data are stored in the object module
related to a specific code file.
The diagram shows that the file "owns"
the variable.
the address can be show like this
int *p2 = new int(3);
int
&
Obj myVar;
a contructor call for this object is not shown
Next
has
has
has
has
has
create
has
points to
delete
has
has
has
has
has
create
has
points to
delete
has
is
is
has
has
create
has