If you don't do C, all you need to understand is that I'm very stupid.mystruct *create(int bar) {
mystruct *a;
a = (mystruct *) malloc(sizeof(mystruct));
a->foo = bar;
return a;
}
mystruct *add(mystruct *a, mystruct *b) {
return create(a->foo + b->foo);
}
int main() {
mystruct *leaky_goodness;
leaky_goodness = add(create(1), create(2));
printf("I leaked all over myself: ", leaky_goodness->foo);
return 0;
}
If you do do C and you still don't see it, take a look at what happens to the three mystructs I create... Oh, and at least I noticed it :)





Comments