Answer the question
In order to leave comments, you need to log in
Where is the string returned by mmap(2) stored?
And is it necessary to free the memory at this pointer using free()?
char *ptr = mmap(NULL, fileLength, PROT_READ, MAP_PRIVATE, input, 0);
Answer the question
In order to leave comments, you need to log in
Why not read the documentation.
man7.org/linux/man-pages/man2/mmap.2.html
1) mmap does not return a string. It returns a pointer to the beginning of the mapped area (void*).
2) It is not necessary to release the area, it will be freed when the process is completed. But if you want, there is unmap.
3) It is strictly forbidden to call free on something not allocated by malloc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question