summaryrefslogtreecommitdiff
path: root/legacy/escape/src/lib/escape_mman.c
diff options
context:
space:
mode:
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-11-05 17:50:23 +0000
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-11-05 17:50:23 +0000
commitfff15361e37f008667bf7c45db6fdc99d89e2ef4 (patch)
tree07094e1c4faf63a8c5c288aaf268be9238692436 /legacy/escape/src/lib/escape_mman.c
parentaeb68dfc9289657071bef0e4d6e298b358bde91f (diff)
Escape: ecrustified
SVN revision: 64786
Diffstat (limited to 'legacy/escape/src/lib/escape_mman.c')
-rw-r--r--legacy/escape/src/lib/escape_mman.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/legacy/escape/src/lib/escape_mman.c b/legacy/escape/src/lib/escape_mman.c
index 7b52804328..995c72e7f4 100644
--- a/legacy/escape/src/lib/escape_mman.c
+++ b/legacy/escape/src/lib/escape_mman.c
@@ -11,7 +11,6 @@
11 11
12/***** API *****/ 12/***** API *****/
13 13
14
15void * 14void *
16mmap(void *addr __UNUSED__, 15mmap(void *addr __UNUSED__,
17 size_t len, 16 size_t len,
@@ -20,48 +19,49 @@ mmap(void *addr __UNUSED__,
20 int fd, 19 int fd,
21 off_t offset) 20 off_t offset)
22{ 21{
23 void *data; 22 void *data;
24 size_t size; 23 size_t size;
25 24
26 data = malloc(len); 25 data = malloc(len);
27 if (!data) 26 if (!data)
28 { 27 {
29 fprintf (stderr, "[Escape] [mmap] malloc failed\n"); 28 fprintf (stderr, "[Escape] [mmap] malloc failed\n");
30 return MAP_FAILED; 29 return MAP_FAILED;
31 } 30 }
32 31
33 size = read(fd, data, len); 32 size = read(fd, data, len);
34 if (size != len) 33 if (size != len)
35 { 34 {
36 fprintf (stderr, "[Escape] [mmap] read failed\n"); 35 fprintf (stderr, "[Escape] [mmap] read failed\n");
37 free(data); 36 free(data);
38 return MAP_FAILED; 37 return MAP_FAILED;
39 } 38 }
40 39
41 if (lseek(fd, -len, SEEK_CUR) == -1) 40 if (lseek(fd, -len, SEEK_CUR) == -1)
42 { 41 {
43 fprintf (stderr, "[Escape] [mmap] lseek failed\n"); 42 fprintf (stderr, "[Escape] [mmap] lseek failed\n");
44 free(data); 43 free(data);
45 return MAP_FAILED; 44 return MAP_FAILED;
46 } 45 }
47 46
48 return data; 47 return data;
49} 48}
50 49
51int 50int
52munmap(void *addr, 51munmap(void *addr,
53 size_t len __UNUSED__) 52 size_t len __UNUSED__)
54{ 53{
55 if (addr && (addr != MAP_FAILED)) 54 if (addr && (addr != MAP_FAILED))
56 free(addr); 55 free(addr);
57 56
58 return 0; 57 return 0;
59} 58}
60 59
61 60int
62int madvise(void *addr __UNUSED__, 61madvise(void *addr __UNUSED__,
63 size_t length __UNUSED__, 62 size_t length __UNUSED__,
64 int advice __UNUSED__) 63 int advice __UNUSED__)
65{ 64{
66 return 0; 65 return 0;
67} 66}
67