ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/emman.c
(Generate patch)

Comparing rxvt-unicode/src/emman.c (file contents):
Revision 1.1 by root, Thu Jun 28 15:19:15 2012 UTC vs.
Revision 1.7 by root, Thu Oct 30 21:59:18 2014 UTC

1/* enable mremap on GNU/Linux */
2#ifdef __linux__
3# define _GNU_SOURCE
4#endif
5
6/* enable the POSIX prototypes of mmap/munmap on Solaris */
7#ifdef __sun
8# if __STDC_VERSION__ >= 199901L
9# define _XOPEN_SOURCE 600
10# else
11# define _XOPEN_SOURCE 500
12# endif
13#endif
14
1#include "emman.h" 15#include "emman.h"
2 16
3#include <ecb.h> 17#include <ecb.h>
4 18
5#include <string.h> 19#include <string.h>
6 20
7#ifndef _WIN32 21#ifndef _WIN32
8# include <unistd.h> 22# include <unistd.h>
9#endif 23#endif
10 24
11#if _POSIX_MAPPED_FILES 25#if _POSIX_MAPPED_FILES > 0
12# define USE_MMAP 1 26# define USE_MMAP 1
13# ifdef __linux__
14# define _GNU_SOURCE
15# endif
16# include <sys/mman.h> 27# include <sys/mman.h>
17# ifndef MAP_FAILED 28# ifndef MAP_FAILED
18# define MAP_FAILED ((void *)-1) 29# define MAP_FAILED ((void *)-1)
19# endif 30# endif
20# ifndef MAP_ANONYMOUS 31# ifndef MAP_ANONYMOUS
32# else 43# else
33# define BOOT_PAGESIZE 44# define BOOT_PAGESIZE
34# endif 45# endif
35#else 46#else
36# define PAGESIZE 1 47# define PAGESIZE 1
48# define BOOT_PAGESIZE
37#endif 49#endif
38 50
39size_t 51size_t
40chunk_round (size_t size) 52chunk_round (size_t size)
41{ 53{
116 memcpy (ptr2, ptr, old_size); 128 memcpy (ptr2, ptr, old_size);
117 munmap (ptr, old_size); 129 munmap (ptr, old_size);
118 return ptr2; 130 return ptr2;
119 #endif 131 #endif
120 #else 132 #else
121 return realloc (ptr, size); 133 return realloc (ptr, new_size);
122 #endif 134 #endif
123} 135}
124 136
125void 137void
126chunk_free (void *ptr, size_t size) 138chunk_free (void *ptr, size_t size)
127{ 139{
128 #if USE_MMAP 140 #if USE_MMAP
141 /* we assume the OS never mmaps at address 0 */
142 if (ptr)
129 munmap (ptr, size); 143 munmap (ptr, size);
130 #else 144 #else
131 return free (ptr); 145 return free (ptr);
132 #endif 146 #endif
133} 147}
134 148

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines