I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc
you should call free
and when you use the
new
will initialise the default values of the struct and correctly links the references in it to itself.
E.g.
struct test_s {
int some_strange_name = 1;
int &easy = some_strange_name;
}
So new struct test_s
will return an initialised structure with a working reference, while the malloc'ed version has no default values and the intern references aren't initialised.