>>7
is that in some way official because using a size in the sizeof(int) of the machine seems retarded, in
Refcount r = malloc(sizeof(int)+size);
Name:
Anonymous2012-01-09 16:13
That's reference counting, but not automatic memory management.
I.e, instead of
{
obj = CreateSomeObject(..);
// do something with obj
// but don't forget to free the memory before a leak occurs!
free(obj);
}
It should be, in an ideal world without GC and no free():
{
obj = CreateSomeObject(...);
// do something with obj
// fuck free(), the compiler should auto-insert free(obj)
// when the object is not in scope anymore.
}
Name:
Anonymous2012-01-09 16:15
>>9
I wrote that in 5 minutes, and I originally used int n and changed it to size_t n, but forgot to change the malloc size.
Name:
Anonymous2012-01-09 16:17
>>10 {
SomeObject obj;
InitSomeObj(&obj);
// do something with obj
}
{
SomeObject obj = DEFAULT_SOME_OBJ;
// do something with obj
}