Thread: problem in freeing a "tree" of stuctures

  1. #16
    Registered User
    Join Date
    Nov 2008
    Posts
    14
    Quote Originally Posted by tabstop View Post
    And how does it "not work"?
    i get a segmentation fault

    I've tried to do some print on screen to understand why
    as it seems it occurs while trying to run a FreedVector(curs->point,3);
    and it is not possible to print out that vector point even if curs is not a NULL pointer

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    So that node apparently doesn't have a point vector? Is that expected? If so, you'll have to deal with that. If not, you should check that you didn't forget to do so?

  3. #18
    Registered User
    Join Date
    Nov 2008
    Posts
    14
    Quote Originally Posted by tabstop View Post
    So that node apparently doesn't have a point vector? Is that expected? If so, you'll have to deal with that. If not, you should check that you didn't forget to do so?
    it is not expected and it shouldn't be possible
    the vector point is the information of the node without that the node shouldn't even exist

    edit
    and I find quite strange that if there is no point vector in that node I don't get an error previously in the program while trying to use that vector that don't exist
    Last edited by stealthisnick; 11-12-2008 at 11:08 AM.

  4. #19
    Registered User
    Join Date
    Nov 2008
    Posts
    14
    some news, I don't know if good or bad ones
    as it seems if I change the input file to an easier one, it works
    or at least it does not give me the segmentation fault

    so it might be a problem in the allocation rather than in freeing the memory, am I wrong?

    edit

    there is a way to check if the memory is freed for real? (to check if the function actually works)
    Last edited by stealthisnick; 11-13-2008 at 03:19 AM.

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by stealthisnick View Post
    some news, I don't know if good or bad ones
    as it seems if I change the input file to an easier one, it works
    or at least it does not give me the segmentation fault

    so it might be a problem in the allocation rather than in freeing the memory, am I wrong?

    edit

    there is a way to check if the memory is freed for real? (to check if the function actually works)
    Most implementations of the C runtime library has some functions that tell you the state of the heap. However, those are unique to the C runtime library, and non-standard, so you'd have to tell us which C library (which compiler) you are using.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #21
    Registered User
    Join Date
    Nov 2008
    Posts
    14
    Quote Originally Posted by matsp View Post
    Most implementations of the C runtime library has some functions that tell you the state of the heap. However, those are unique to the C runtime library, and non-standard, so you'd have to tell us which C library (which compiler) you are using.

    --
    Mats
    well, I run that program on a UNIX station so I have a command to compile and that's it, as far as I know

  7. #22
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by stealthisnick View Post
    well, I run that program on a UNIX station so I have a command to compile and that's it, as far as I know
    That's not quite enough information to tell us what C library you are using, and as it's unique to each C library, we can't tell.

    Alternatively, you could make your own malloc/free replacement functions that keep track of how much you've allocated and how much you've freed.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #23
    Registered User
    Join Date
    Nov 2008
    Posts
    14
    Quote Originally Posted by matsp View Post
    That's not quite enough information to tell us what C library you are using, and as it's unique to each C library, we can't tell.
    so how can I see what C library I'm using?

  9. #24
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by stealthisnick View Post
    so how can I see what C library I'm using?
    By either telling us what compiler it is, or by looking at the linker stage of the compilation (which you may not normally see, so you may have to change your makefile or such to get that out).

    What flavour of Unix is it?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #25
    Registered User
    Join Date
    Nov 2008
    Posts
    14
    Quote Originally Posted by matsp View Post
    By either telling us what compiler it is, or by looking at the linker stage of the compilation (which you may not normally see, so you may have to change your makefile or such to get that out).

    What flavour of Unix is it?

    --
    Mats
    as I've said I have no idea what compiler it is, I just have a file with the command
    Code:
    cc -g namefile.c ./lib/sol/*.o -lm -o namefile
    and that's all I know about how I compile it

    about UNIX it should be (actually I'm using it remotely with X-Win32) Solaris OS (if that was the question)

  11. #26
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Maybe this page (I didn't actually read much of it) will help:
    http://developers.sun.com/solaris/ar...m_library.html

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #27
    Registered User
    Join Date
    Nov 2008
    Posts
    14
    I'll have a look, thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Some help with "realloc invalid next size" problem?
    By ninboy in forum C Programming
    Replies: 6
    Last Post: 05-20-2008, 11:57 AM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM