Results 1 to 3 of 3

Thread: CList Troubles

  1. #1
    needaname16
    Guest

    Unhappy CList Troubles

    Hi,

    I have been using a CList to statically store data between two processes, my problem is the debugger shows that data is being lost or changed from when it was added to the list to when it is retrieved from the list. I have a reasonably large structure being stored in the list. My declaration is :

    CList<MyStrucutre, MyStructure&> MyList;

    MyStructure {
    char sString1[256];
    short iParameter2;
    char sString2[256];
    /* Down to sString18[256] with some short members */
    }

    Basically I have a DLL putting items in the list and retrieving items from the list and other DLLs use these functions to store/retrieve data.

    I have tried a number of ways to try to get around this the only thing that worked was to reduce the structure. I need to be able to store a number of elements with the data above, therefore the only solution I can come up with is to use a file I/O instead with windows API.

    Does anyone have any better suggestions to replace the List?

    Please I'm Desperate as files are not a good solution.

    Needaname16

  2. #2
    amac
    Guest
    You could use pointers instead of character arrays. Then dynamically allocate memory for each string you need... This way the memory that your structure consumes is split between the stack and the heap.

    This also means you have to clean up each of these elements before it goes out of scope.

    You could use a linked list.

    Actually even if you used CList but stored pointers instead of the actual structure it might help...

    Code:
    CList <MyStruct *, MyStruct *& > MyList;

  3. #3
    needaname16
    Guest

    Oops...

    Hi,

    When I debugged further I actually found the problem lies elsewhere, it is data exchange between two functions in seperate DLLs. It appears the structure I am passing loses its data when I pass it from one DLL to the next. I am passing the structures values using the following declaraction

    MyStructure MyEntry;

    The calling DLL where the structure already contains it's values:

    funAddtoList (MyEntry);

    __declspec (dllexport) void funAddtoList (MyStructure EntryToAdd);

    When I look at the structures values here they have changed. Does anyone know why or have any suggestions on how to fix this (note I have also tried to pass a pointer to the structure without success)?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width