BPsite Forums
November 23, 2024, 05:34:15 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: BPSITE FOREVER!
 
  Home Help Search Members Login Register  
  Show Posts
Pages: [1]
1  BPSITE / Geek's Corner / The Gathering of Programmers on: November 06, 2005, 12:44:30 PM
Quote
Things I should add to my polynomial program:
  • De-allocate my linked lists at the end of the program:
    • From the main: poly1, poly2, sum, prod…
      [li]From other functions free up individual links at the end of the function: current, preS, preC, slot…
I should have put this in the other post but its late, and i've been working on java homework Shocked
you really don't want to free the individual links...
*gets out a soapbox, steps up and begins a speach*
since you dont copy the contents of the struct around, freeing up your current, preS, preC, etc... at the end of those functions will "inadvertently" free up the node in your linked list, then if you go and try to free up your list, you'll get heap overflow... returning more memory than you were allocated.
The best option for your other functions is to set the current, preS, preC, etc... pointers null as the last thing you do in the function.
*takes a bow, picks up the soapbox and puts it away*
 :ph34r:
2  BPSITE / Geek's Corner / The Gathering of Programmers on: November 06, 2005, 12:11:05 PM
Quote
Could some please tell me why I’m getting those errors.   :unsure:
I think in your POLY struct if you change
struct POLY * next;
to
POLY * next;
it will get rid of a bunch of those errors warnings...
if that causes it to not even run, then look through configuration/preferences and turn the warning level down.
It seems to think that a "struct POLY*" is incompatible with "POLY *" :blink: .
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!