comparison src/lib/mmap-util.c @ 183:4a7ab9e94f25 HEAD

size_t fixes for lib/. Changed OFF_T_FORMAT to PRIuOFF_T which is more C99-like.
author Timo Sirainen <tss@iki.fi>
date Sun, 08 Sep 2002 16:20:28 +0300
parents 526284657da7
children ed0d5b17c7a4
comparison
equal deleted inserted replaced
182:7fc832e6bab4 183:4a7ab9e94f25
32 32
33 size = lseek(fd, 0, SEEK_END); 33 size = lseek(fd, 0, SEEK_END);
34 if (size == -1) 34 if (size == -1)
35 return MAP_FAILED; 35 return MAP_FAILED;
36 36
37 if (size > INT_MAX) { 37 if (size > SSIZE_T_MAX) {
38 /* too large file to map into memory */ 38 /* too large file to map into memory */
39 errno = EFBIG; 39 errno = EFBIG;
40 return MAP_FAILED; 40 return MAP_FAILED;
41 } 41 }
42 42
43 *length = (size_t)size; 43 *length = (size_t)size;
44 if (*length == 0) 44 if (*length == 0)
45 return NULL; 45 return NULL;
46 46
47 i_assert(*length > 0 && *length < INT_MAX); 47 i_assert(*length > 0 && *length < SSIZE_T_MAX);
48 48
49 return mmap(NULL, *length, access, MAP_SHARED, fd, 0); 49 return mmap(NULL, *length, access, MAP_SHARED, fd, 0);
50 } 50 }
51 51
52 void *mmap_ro_file(int fd, size_t *length) 52 void *mmap_ro_file(int fd, size_t *length)