quindi scusa, ipotizzando che il codice che ho scritto direttamente qui funzioni potrei invece riscrivelo come sotto
codice:
int Size = Socket->ReceiveLength();
char *Buf = (char *)malloc(Size * sizeof(char *));
int ByteRecived = Socket->ReceiveBuf(Buf, Size);
Buf[Size] = '\0';
if(Size > 0)
{
Buffer = (char *)realloc(Buffer,strlen(Buffer) + Size );
strcat(Buffer,Buf);
free(Buf);
}
senza occuparmi dell'allocazione di memoria?
codice:
int Size = Socket->ReceiveLength();
String Buf;
int ByteRecived = Socket->ReceiveBuf(Buf, Size);
if(Size > 0)
{
String Buffer;
Buffer=Buffer+Buf;
}
Il Buffer poi lo si eliminerebbe con un delete [] Buffer; pur non avendo usato loperatore new oppure è sufficiente il riutilizzo (richiamo della stessa funzione) per deallocare automaticamente il Buffer?