Does the distribution of an instance structusing mallocaffect the distribution of its members? That means doing something like this:
typedef struct { int *i; } test;
int main() {
test *t = malloc(sizeof(test));
t->i = malloc(sizeof(int));
}
... doesn't make sense because it ishould already be on the heap, right?
Or, is the structure simply conceptual to help a group of programmers two completely separate variables floating in memory? This means that: test *t = malloc(sizeof(test))just allocates memory to store pointers to items on the heap?
I am pretty puzzled by this.
source
share