1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Rep Power

    Lightbulb Best way to memory alloc/display?


    Ive got a linked list structure which contains a command structure.

    Oviously internally my program stores it in its own datastructure but externally it takes the form of english looking commands such as


    I need to walk this list and display the contents into a Edit control to enable the user to view it. I have a function which returns the command as a char * (english style).

    However I dont know how many commands are present and I cant seem to append items to the edit control (WIN32/c only no mfc). So I thought why not read it all into a string and then send it in one go. However since I dont know the total size before hand it will prob mean assigning memory on the fly. I know about malloc/free but how can I repeatdly do this in a loop or is there a way to append to a edit control instead of adding it in one big char chunk?

    Thanks your views and ideas would be welcomed.

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Back in the real world.
    Rep Power
    for allocating more memory to an already assigned variable, you can use realloc() to extend the space.

    i am no pro in windows programming, but i remember there is a WM_GETTEXT message which should help you in appending.
    since this comes back to using #1, you should use one string and write it once to the edit control.

IMN logo majestic logo threadwatch logo seochat tools logo