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

C Heap dongs

Name: Anonymous 2011-07-18 21:19

I keep getting heap corruption with the following code:

http://pastebin.com/gGdgPiYa

it occurs @ line 132 : free(queue_poll(q));

i checked it with a debugger and my polled element was still there and not Null or anything so why isn't it allowing to be freed? Also i use the queue code with another application that doesn't free the polled element and i end up memory leaks but if i try to free the element when i'm finish using it it heap corruptions me.

Header looks like:
http://pastebin.com/AwFKQcGe


queue_init(...) is no longer used i just haven't bothered to take it out btw so pay no attention to it.

Name: Anonymous 2011-07-18 22:11

Might I recommend renaming poll to pop? Thanks.

>>7
You should use sizeof(*ty), not sizeof(struct ty). This way if the type of ty changes, the code will still work.

Also? Never fucking name a variable the same thing as a struct! I don't care if C has a separate namespace for struct tags. It's bad.

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