ddoherty@ics.uci.edu (Donald Doherty) (01/28/91)
I allocated global memory for use by a three dimensional array in the following way... #define LTSTOP 605 #define NCLS 50 #define NCPOPS 3 . . static GLOBALHANDLE hPSomaMemory; static GLOBALHANDLE hPSoma1Memory; static GLOBALHANDLE hPSoma2Memory; static GLOBALHANDLE hPSoma3Memory; . . hPSomaMemory = GlobalAlloc (GMEM_MOVEABLE, NCPOPS * sizeof(int)); hPSoma1Memory = GlobalAlloc (GMEM_MOVEABLE, NCLS * LTSTOP * sizeof(int)); hPSoma2Memory = GlobalAlloc (GMEM_MOVEABLE, NCLS * LTSTOP * sizeof(int)); hPSoma3Memory = GlobalAlloc (GMEM_MOVEABLE, NCLS * LTSTOP * sizeof(int)); . . lpPSoma = (int FAR **) GlobalLock (hPSomaMemory); lpPSoma[0] = (int FAR *) GlobalLock (hPSoma1Memory); lpPSoma[1] = (int FAR *) GlobalLock (hPSoma2Memory); lpPSoma[2] = (int FAR *) GlobalLock (hPSoma3Memory); . . for (i = 0; i < NCPOPS; i++) for (j = 0; j < NCLS; j++) lpPSoma[i][j * LTSTOP + l] = ...; It works but it seems rather messy. (However I do get a Warning at compile time: segment lost in conversion. Any ideas why?) Is there a better way to do this? If I want **lpPSoma to point to an array containing four addresses to arrays rather than three (or n addresses for that matter) I would need four separate handles, one for each array. I initially attempted to declare a huge int array as shown below. int huge *lpPSoma; . . hPSomaMemory = GlobalAlloc (GMEM_MOVEABLE, NCPOPS * NCLS * LTSTOP * sizeof(int)); . . for (i = 0; i < NCPOPS; i++) for (j = 0; j < NCLS; j++) lpPSoma[(i * NCLS * LTSTOP) + (j * LTSTOP) + l] =...; This is much cleaner but crashes (run time, no compiler warnings) when the array exceeds segment size (64k). I must be using it incorrectly somehow. I will be grateful for any help in using GlobalAlloc (and huge?) correctly. I would eventually like to use MUCH larger arrays than those that I am working with now. Thank-you! Don D. ddoherty@ICS.uci.edu