Accessing structure members

This is a discussion on Accessing structure members within the C Programming forums, part of the General Programming Boards category; Freeing a list is even simpler: Code: void freeList( Node *n ) { if( n ) freeList( n->next ); free( ...

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Freeing a list is even simpler:
    Code:
    void freeList( Node *n )
    {
        if( n ) freeList( n->next );
        free( n );
    }
    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Sayeh
    Guest

    What happens to RAM when app ends

    In reponse to folks' uncertainties about what happens when a program ends--

    In any properly written operating system (which is all except that written by Microsoft -- DOS being the only correctly done O/S), whenever an application ends, the Memory Manager disposes of the heap.

    It has no other use for it, so since it's just a RAMblock like any other, it's deallocated.

    ---

    With Microsoft, it's a toss up whether they are failing to deallocate because they are stupid, or whether the code is so bad it's just a "leak"....


    enjoy.

  3. #18
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,689
    > if( n ) freeList( n->next );
    Ouch - that could create some unnecessary stack problems

  4. #19
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > if( n ) freeList( n->next );
    Ouch - that could create some unnecessary stack problems
    Only if you have circular loop. Otherwise I don't see a problem
    (unless you have some massive list, over 100000 elements or
    something).

    Since no variables are declared in this function, it being recursive
    is not really much of a strain. You should have barely any over-
    head for the function call.

    All you're doing is going to the end of the list, then free it, fall
    back one, free that, repeat.

    Quzah.
    Hope is the first step on the road to disappointment.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I point to structure members?
    By RaisinToe in forum C++ Programming
    Replies: 2
    Last Post: 03-07-2009, 10:34 PM
  2. Regarding accessing the structure member
    By kollurisrinu in forum C Programming
    Replies: 5
    Last Post: 06-18-2008, 04:51 AM
  3. Help...accessing character arrays in a structure
    By mathewmc in forum C Programming
    Replies: 7
    Last Post: 10-31-2006, 10:20 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 09:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21