Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prague/ Q&A

Name: Anonymous 2013-11-19 12:18

Ask /prog/ anything.

Although don't expect an answer or even a good one.

Also, keep it /prog/ related.

Name: Anonymous 2013-11-20 14:21

>>22
Did I fuck up the scoping and deleted the *Phonebook in input() when it ended?

First of all, you've got a poor understanding of C's manual memory management. You lost the address of the new Record you allocated, but it's still on the heap taking up space. That's a memory leak. Someone's gonna point that out and it might as well be me.

And second, yeah, you'll want to change Phonebook to a Record **, and rewrite that last section as follows:

if (Phonebook != NULL) {
if (*Phonebook == NULL) {
*Phonebook = New;
} else {
Temp = *Phonebook;
// ...
}
} else {
// Signal an error and/or deallocate New
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List