i'm sending a NULL pointer of type unsigned char to a function. i allocate space for this pointer in the function and return nothing.
unsigned char ucBufr = NULL;
Allocation(ucBufr);
void Allocation(unsigned char * ucBufr)
{
/* nDataSize and ucData is got from a file here. */
ucBufr = malloc(nDataSize);
ucBufr[0] = 'B';
ucBufr[1] = 'U';
memcpy(ucBufr+2,ucData,nDataSize);
/* ... */
}
what i want to be sure is, after function statements does the allocation space dissapear? i do not get any errors, but i do not want to fall into segmentation faults further in my program. why i am asking this is because I know that after function statements local variables which are defined in the function are freed by the O/S. Could we expect the same bad event with malloc?
Thanx.