So, jetzt scheint alles zu klappen:D
Ich hab deine Funktion etwas abgeändert Klotzkopp, aber vom
Prinzip her ist es die Selbe:
void ProcessData(char *buffer, int size)
{
int nPos=0;
nAnzahl=0;
for( int i=0; i<size; ++i )
{
if( buffer[i] == '\0' )
{
lpCurrentMsg = (char*)realloc(lpCurrentMsg,_msize(lpCurrentMsg)+1);
lpCurrentMsg[nPos] = '\0';
if (lpMessages == NULL)
lpMessages = (char**)calloc(1,sizeof(char*));
else
lpMessages = (char**) realloc(lpMessages,_msize(lpMessages) + sizeof(char*));
lpMessages[nAnzahl] = (char*) calloc(strlen(lpCurrentMsg)+1,sizeof(char));
strcpy(lpMessages[nAnzahl],lpCurrentMsg);
free(lpCurrentMsg);
lpCurrentMsg = NULL;
nAnzahl++;
nPos=0;
continue;
}
if (lpCurrentMsg == NULL)
lpCurrentMsg = (char*)calloc(1,sizeof(char));
else
lpCurrentMsg = (char*)realloc(lpCurrentMsg,_msize(lpCurrentMsg)+1);
lpCurrentMsg[nPos] = buffer[i];
nPos++;
}
}
[/PHP]
Ich hoffe es entstehen nicht zuviele Speicherlecks:rolleyes:
Danke euch beiden, ihr habt mir sehr geholfen.
Gruß
Guybrush