Hi, I am trying to pass data to a .DLL I want to use. DLL accepts this structure for its data.
Code:
PTR 01FB317C -> 01EEB208 -> ASCII "DATA0"
018947A0 -> 01F72f30 -> ASCII "DATA1"
+8 01F74558 -> ASCII "DATA2"
+12 01F742E8 -> ASCII "DATA3"
+16 01F73FF8 -> ASCII "DATA4"
+20 01FD3CF8 -> ASCII "DATA5"
+24 01FD4EC8 -> ASCII "DATA6"
+28 01F724D8 -> ASCII "DATA7"
+32 -> ASCII "DATA8"
+36 -> ASCII "DATA9"
+40 -> ASCII "DATA10"
+44 -> ASCII "DATA11"
+48 -> ASCII "DATA12"
Pointers are from a call from real application.ASCII strings are of size 256.
So i created this structure:
Code:
typedef struct
{
char *s1;
char ** ss1;
} Rec1;
Now I am trying to malloc before I put data on it
Code:
Rec1 *a;
a = (Rec1 *)malloc(sizeof(Rec1));
a->s1 = (char*)malloc(16*sizeof(char));
strcpy(a->s1, "DATA0"); <--- This works OK as seen on debugger
a->ss1 = (char**) malloc(48); <--- !CRASH!!! ; Trying to allocate space for pointers
for( i=0; i < 12; i++)
a->ss1[i] = (char *)malloc(256);
strcpy(a->ss1[0], "DATA1");
.......
free(a);
for( i=0; i < 12; i++)
free( a->ss1[i] );
free( a->ss1 );
Problem is the above malloc() crashes with C0000005
Can you help me how is the correct way to do it?
PS: On 1st declaration of structure it is char *........1; I keep editing the message and it keeps ignoring my edit always showing ......1; !!!! @#!
PS2: I managed to do it