Skip to content

Commit 7ab7bf4

Browse files
committed
p_fallocate: don't duplicate definitions for win32
1 parent 32f5045 commit 7ab7bf4

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/posix.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,23 @@ int p_rename(const char *from, const char *to)
155155
return -1;
156156
}
157157

158+
int p_fallocate(int fd, off_t offset, off_t len)
159+
{
160+
#ifdef __APPLE__
161+
fstore_t prealloc;
162+
163+
memset(&prealloc, 0, sizeof(prealloc));
164+
prealloc.fst_flags = F_ALLOCATEALL;
165+
prealloc.fst_posmode = F_PEOFPOSMODE;
166+
prealloc.fst_offset = offset;
167+
prealloc.fst_length = len;
168+
169+
return fcntl(fd, F_PREALLOCATE, &prealloc);
170+
#else
171+
return posix_fallocate(fd, offset, len);
172+
#endif
173+
}
174+
158175
#endif /* GIT_WIN32 */
159176

160177
ssize_t p_read(git_file fd, void *buf, size_t cnt)
@@ -216,23 +233,6 @@ int p_write(git_file fd, const void *buf, size_t cnt)
216233
return 0;
217234
}
218235

219-
int p_fallocate(int fd, off_t offset, off_t len)
220-
{
221-
#ifdef __APPLE__
222-
fstore_t prealloc;
223-
224-
memset(&prealloc, 0, sizeof(prealloc));
225-
prealloc.fst_flags = F_ALLOCATEALL;
226-
prealloc.fst_posmode = F_PEOFPOSMODE;
227-
prealloc.fst_offset = offset;
228-
prealloc.fst_length = len;
229-
230-
return fcntl(fd, F_PREALLOCATE, &prealloc);
231-
#else
232-
return posix_fallocate(fd, offset, len);
233-
#endif
234-
}
235-
236236
#ifdef NO_MMAP
237237

238238
#include "map.h"

0 commit comments

Comments
 (0)