Thread: Pointers to pointers

  1. #16
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    It's better to do this by the way:

    Code:
    char **temp = realloc( count * sizeof(stringList) );
    if ( temp != NULL ) {
       stringList = temp;
    }
    else {
       free( stringList );
       logerrors(  );
    }
    The reason is because if realloc fails, it will return NULL. You would leak the old memory if you simply reassigned like you did.

    Although I agree that if you're right and the string object doesn't work, you ought to make your own string object that has the inner workings you require. That way you can just do:

    psychoxixString stringList[ MAX ]; or whatever is actually appropriate.

  2. #17
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you cannot use the MSVC version of the STL perhaps you could use STL port? I actually recommend using it even if you can use the MSVC STL.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of struct with pointers and function pointers
    By sdsjohnny in forum C Programming
    Replies: 3
    Last Post: 07-02-2010, 05:19 AM
  2. Storing function pointers in generic pointers
    By Boxknife in forum C Programming
    Replies: 6
    Last Post: 08-01-2009, 01:33 PM
  3. Variable pointers and function pointers
    By Luciferek in forum C++ Programming
    Replies: 11
    Last Post: 08-02-2008, 02:04 AM
  4. Pointers to objects -- passing and returning pointers
    By 1veedo in forum C++ Programming
    Replies: 4
    Last Post: 04-04-2008, 11:42 AM
  5. weak pointers and use_count smart pointers
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 07-29-2006, 07:54 AM