mirror of
https://github.com/git/git.git
synced 2024-09-26 17:31:13 +02:00
compat: let git_mmap use malloc(3) directly
xmalloc() dies on error, allows zero-sized allocations and enforces GIT_ALLOC_LIMIT for testing. Our mmap replacement doesn't need any of that. Let's cut out the wrapper, reject zero-sized requests as required by POSIX and use malloc(3) directly. Allocation errors were needlessly handled by git_mmap() before; this code becomes reachable now. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ebf3c04b26
commit
95b4ff3931
@ -7,7 +7,12 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
|
|||||||
if (start != NULL || flags != MAP_PRIVATE || prot != PROT_READ)
|
if (start != NULL || flags != MAP_PRIVATE || prot != PROT_READ)
|
||||||
die("Invalid usage of mmap when built with NO_MMAP");
|
die("Invalid usage of mmap when built with NO_MMAP");
|
||||||
|
|
||||||
start = xmalloc(length);
|
if (length == 0) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return MAP_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
start = malloc(length);
|
||||||
if (start == NULL) {
|
if (start == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
|
Loading…
Reference in New Issue
Block a user