Werner Lemberg pushed to branch master at FreeType / FreeType
Commits:
-
68940241
by Werner Lemberg at 2021-02-02T09:44:42+01:00
2 changed files:
Changes:
1 |
-/***************************************************************************/
|
|
2 |
-/* */
|
|
3 |
-/* ftsystem.c */
|
|
4 |
-/* */
|
|
5 |
-/* Unix-specific FreeType low-level system interface (body). */
|
|
6 |
-/* */
|
|
7 |
-/* Copyright (C) 1996-2021 by */
|
|
8 |
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
9 |
-/* */
|
|
10 |
-/* This file is part of the FreeType project, and may only be used, */
|
|
11 |
-/* modified, and distributed under the terms of the FreeType project */
|
|
12 |
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
13 |
-/* this file you indicate that you have read the license and */
|
|
14 |
-/* understand and accept it fully. */
|
|
15 |
-/* */
|
|
16 |
-/***************************************************************************/
|
|
1 |
+/****************************************************************************
|
|
2 |
+ *
|
|
3 |
+ * ftsystem.c
|
|
4 |
+ *
|
|
5 |
+ * Unix-specific FreeType low-level system interface (body).
|
|
6 |
+ *
|
|
7 |
+ * Copyright (C) 1996-2021 by
|
|
8 |
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
9 |
+ *
|
|
10 |
+ * This file is part of the FreeType project, and may only be used,
|
|
11 |
+ * modified, and distributed under the terms of the FreeType project
|
|
12 |
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
13 |
+ * this file you indicate that you have read the license and
|
|
14 |
+ * understand and accept it fully.
|
|
15 |
+ *
|
|
16 |
+ */
|
|
17 | 17 |
|
18 | 18 |
|
19 | 19 |
#include <ft2build.h>
|
... | ... | @@ -70,29 +70,40 @@ |
70 | 70 |
#include <errno.h>
|
71 | 71 |
|
72 | 72 |
|
73 |
- /*************************************************************************/
|
|
74 |
- /* */
|
|
75 |
- /* MEMORY MANAGEMENT INTERFACE */
|
|
76 |
- /* */
|
|
77 |
- /*************************************************************************/
|
|
78 |
- |
|
79 |
- |
|
80 |
- /*************************************************************************/
|
|
81 |
- /* */
|
|
82 |
- /* <Function> */
|
|
83 |
- /* ft_alloc */
|
|
84 |
- /* */
|
|
85 |
- /* <Description> */
|
|
86 |
- /* The memory allocation function. */
|
|
87 |
- /* */
|
|
88 |
- /* <Input> */
|
|
89 |
- /* memory :: A pointer to the memory object. */
|
|
90 |
- /* */
|
|
91 |
- /* size :: The requested size in bytes. */
|
|
92 |
- /* */
|
|
93 |
- /* <Return> */
|
|
94 |
- /* The address of newly allocated block. */
|
|
95 |
- /* */
|
|
73 |
+ /**************************************************************************
|
|
74 |
+ *
|
|
75 |
+ * MEMORY MANAGEMENT INTERFACE
|
|
76 |
+ *
|
|
77 |
+ */
|
|
78 |
+ |
|
79 |
+ |
|
80 |
+ /**************************************************************************
|
|
81 |
+ *
|
|
82 |
+ * It is not necessary to do any error checking for the
|
|
83 |
+ * allocation-related functions. This will be done by the higher level
|
|
84 |
+ * routines like ft_mem_alloc() or ft_mem_realloc().
|
|
85 |
+ *
|
|
86 |
+ */
|
|
87 |
+ |
|
88 |
+ |
|
89 |
+ /**************************************************************************
|
|
90 |
+ *
|
|
91 |
+ * @Function:
|
|
92 |
+ * ft_alloc
|
|
93 |
+ *
|
|
94 |
+ * @Description:
|
|
95 |
+ * The memory allocation function.
|
|
96 |
+ *
|
|
97 |
+ * @Input:
|
|
98 |
+ * memory ::
|
|
99 |
+ * A pointer to the memory object.
|
|
100 |
+ *
|
|
101 |
+ * size ::
|
|
102 |
+ * The requested size in bytes.
|
|
103 |
+ *
|
|
104 |
+ * @Return:
|
|
105 |
+ * The address of newly allocated block.
|
|
106 |
+ */
|
|
96 | 107 |
FT_CALLBACK_DEF( void* )
|
97 | 108 |
ft_alloc( FT_Memory memory,
|
98 | 109 |
long size )
|
... | ... | @@ -103,26 +114,30 @@ |
103 | 114 |
}
|
104 | 115 |
|
105 | 116 |
|
106 |
- /*************************************************************************/
|
|
107 |
- /* */
|
|
108 |
- /* <Function> */
|
|
109 |
- /* ft_realloc */
|
|
110 |
- /* */
|
|
111 |
- /* <Description> */
|
|
112 |
- /* The memory reallocation function. */
|
|
113 |
- /* */
|
|
114 |
- /* <Input> */
|
|
115 |
- /* memory :: A pointer to the memory object. */
|
|
116 |
- /* */
|
|
117 |
- /* cur_size :: The current size of the allocated memory block. */
|
|
118 |
- /* */
|
|
119 |
- /* new_size :: The newly requested size in bytes. */
|
|
120 |
- /* */
|
|
121 |
- /* block :: The current address of the block in memory. */
|
|
122 |
- /* */
|
|
123 |
- /* <Return> */
|
|
124 |
- /* The address of the reallocated memory block. */
|
|
125 |
- /* */
|
|
117 |
+ /**************************************************************************
|
|
118 |
+ *
|
|
119 |
+ * @Function:
|
|
120 |
+ * ft_realloc
|
|
121 |
+ *
|
|
122 |
+ * @Description:
|
|
123 |
+ * The memory reallocation function.
|
|
124 |
+ *
|
|
125 |
+ * @Input:
|
|
126 |
+ * memory ::
|
|
127 |
+ * A pointer to the memory object.
|
|
128 |
+ *
|
|
129 |
+ * cur_size ::
|
|
130 |
+ * The current size of the allocated memory block.
|
|
131 |
+ *
|
|
132 |
+ * new_size ::
|
|
133 |
+ * The newly requested size in bytes.
|
|
134 |
+ *
|
|
135 |
+ * block ::
|
|
136 |
+ * The current address of the block in memory.
|
|
137 |
+ *
|
|
138 |
+ * @Return:
|
|
139 |
+ * The address of the reallocated memory block.
|
|
140 |
+ */
|
|
126 | 141 |
FT_CALLBACK_DEF( void* )
|
127 | 142 |
ft_realloc( FT_Memory memory,
|
128 | 143 |
long cur_size,
|
... | ... | @@ -136,19 +151,21 @@ |
136 | 151 |
}
|
137 | 152 |
|
138 | 153 |
|
139 |
- /*************************************************************************/
|
|
140 |
- /* */
|
|
141 |
- /* <Function> */
|
|
142 |
- /* ft_free */
|
|
143 |
- /* */
|
|
144 |
- /* <Description> */
|
|
145 |
- /* The memory release function. */
|
|
146 |
- /* */
|
|
147 |
- /* <Input> */
|
|
148 |
- /* memory :: A pointer to the memory object. */
|
|
149 |
- /* */
|
|
150 |
- /* block :: The address of block in memory to be freed. */
|
|
151 |
- /* */
|
|
154 |
+ /**************************************************************************
|
|
155 |
+ *
|
|
156 |
+ * @Function:
|
|
157 |
+ * ft_free
|
|
158 |
+ *
|
|
159 |
+ * @Description:
|
|
160 |
+ * The memory release function.
|
|
161 |
+ *
|
|
162 |
+ * @Input:
|
|
163 |
+ * memory ::
|
|
164 |
+ * A pointer to the memory object.
|
|
165 |
+ *
|
|
166 |
+ * block ::
|
|
167 |
+ * The address of block in memory to be freed.
|
|
168 |
+ */
|
|
152 | 169 |
FT_CALLBACK_DEF( void )
|
153 | 170 |
ft_free( FT_Memory memory,
|
154 | 171 |
void* block )
|
... | ... | @@ -159,19 +176,19 @@ |
159 | 176 |
}
|
160 | 177 |
|
161 | 178 |
|
162 |
- /*************************************************************************/
|
|
163 |
- /* */
|
|
164 |
- /* RESOURCE MANAGEMENT INTERFACE */
|
|
165 |
- /* */
|
|
166 |
- /*************************************************************************/
|
|
179 |
+ /**************************************************************************
|
|
180 |
+ *
|
|
181 |
+ * RESOURCE MANAGEMENT INTERFACE
|
|
182 |
+ *
|
|
183 |
+ */
|
|
167 | 184 |
|
168 | 185 |
|
169 |
- /*************************************************************************/
|
|
170 |
- /* */
|
|
171 |
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
172 |
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
173 |
- /* messages during execution. */
|
|
174 |
- /* */
|
|
186 |
+ /**************************************************************************
|
|
187 |
+ *
|
|
188 |
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
|
|
189 |
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
|
|
190 |
+ * messages during execution.
|
|
191 |
+ */
|
|
175 | 192 |
#undef FT_COMPONENT
|
176 | 193 |
#define FT_COMPONENT io
|
177 | 194 |
|
... | ... | @@ -180,17 +197,17 @@ |
180 | 197 |
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
|
181 | 198 |
|
182 | 199 |
|
183 |
- /*************************************************************************/
|
|
184 |
- /* */
|
|
185 |
- /* <Function> */
|
|
186 |
- /* ft_close_stream_by_munmap */
|
|
187 |
- /* */
|
|
188 |
- /* <Description> */
|
|
189 |
- /* The function to close a stream which is opened by mmap. */
|
|
190 |
- /* */
|
|
191 |
- /* <Input> */
|
|
192 |
- /* stream :: A pointer to the stream object. */
|
|
193 |
- /* */
|
|
200 |
+ /**************************************************************************
|
|
201 |
+ *
|
|
202 |
+ * @Function:
|
|
203 |
+ * ft_close_stream_by_munmap
|
|
204 |
+ *
|
|
205 |
+ * @Description:
|
|
206 |
+ * The function to close a stream which is opened by mmap.
|
|
207 |
+ *
|
|
208 |
+ * @Input:
|
|
209 |
+ * stream :: A pointer to the stream object.
|
|
210 |
+ */
|
|
194 | 211 |
FT_CALLBACK_DEF( void )
|
195 | 212 |
ft_close_stream_by_munmap( FT_Stream stream )
|
196 | 213 |
{
|
... | ... | @@ -202,17 +219,17 @@ |
202 | 219 |
}
|
203 | 220 |
|
204 | 221 |
|
205 |
- /*************************************************************************/
|
|
206 |
- /* */
|
|
207 |
- /* <Function> */
|
|
208 |
- /* ft_close_stream_by_free */
|
|
209 |
- /* */
|
|
210 |
- /* <Description> */
|
|
211 |
- /* The function to close a stream which is created by ft_alloc. */
|
|
212 |
- /* */
|
|
213 |
- /* <Input> */
|
|
214 |
- /* stream :: A pointer to the stream object. */
|
|
215 |
- /* */
|
|
222 |
+ /**************************************************************************
|
|
223 |
+ *
|
|
224 |
+ * @Function:
|
|
225 |
+ * ft_close_stream_by_free
|
|
226 |
+ *
|
|
227 |
+ * @Description:
|
|
228 |
+ * The function to close a stream which is created by ft_alloc.
|
|
229 |
+ *
|
|
230 |
+ * @Input:
|
|
231 |
+ * stream :: A pointer to the stream object.
|
|
232 |
+ */
|
|
216 | 233 |
FT_CALLBACK_DEF( void )
|
217 | 234 |
ft_close_stream_by_free( FT_Stream stream )
|
218 | 235 |
{
|
1 |
-/***************************************************************************/
|
|
2 |
-/* */
|
|
3 |
-/* ftsystem.c */
|
|
4 |
-/* */
|
|
5 |
-/* Unix-specific FreeType low-level system interface (body). */
|
|
6 |
-/* */
|
|
7 |
-/* Copyright (C) 1996-2020 by */
|
|
8 |
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
9 |
-/* */
|
|
10 |
-/* This file is part of the FreeType project, and may only be used, */
|
|
11 |
-/* modified, and distributed under the terms of the FreeType project */
|
|
12 |
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
13 |
-/* this file you indicate that you have read the license and */
|
|
14 |
-/* understand and accept it fully. */
|
|
15 |
-/* */
|
|
16 |
-/***************************************************************************/
|
|
1 |
+/****************************************************************************
|
|
2 |
+ *
|
|
3 |
+ * ftsystem.c
|
|
4 |
+ *
|
|
5 |
+ * Windows-specific FreeType low-level system interface (body).
|
|
6 |
+ *
|
|
7 |
+ * Copyright (C) 2021 by
|
|
8 |
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
9 |
+ *
|
|
10 |
+ * This file is part of the FreeType project, and may only be used,
|
|
11 |
+ * modified, and distributed under the terms of the FreeType project
|
|
12 |
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
13 |
+ * this file you indicate that you have read the license and
|
|
14 |
+ * understand and accept it fully.
|
|
15 |
+ *
|
|
16 |
+ */
|
|
17 | 17 |
|
18 | 18 |
|
19 | 19 |
#include <ft2build.h>
|
... | ... | @@ -31,29 +31,40 @@ |
31 | 31 |
#include <stdlib.h>
|
32 | 32 |
|
33 | 33 |
|
34 |
- /*************************************************************************/
|
|
35 |
- /* */
|
|
36 |
- /* MEMORY MANAGEMENT INTERFACE */
|
|
37 |
- /* */
|
|
38 |
- /*************************************************************************/
|
|
39 |
- |
|
40 |
- |
|
41 |
- /*************************************************************************/
|
|
42 |
- /* */
|
|
43 |
- /* <Function> */
|
|
44 |
- /* ft_alloc */
|
|
45 |
- /* */
|
|
46 |
- /* <Description> */
|
|
47 |
- /* The memory allocation function. */
|
|
48 |
- /* */
|
|
49 |
- /* <Input> */
|
|
50 |
- /* memory :: A pointer to the memory object. */
|
|
51 |
- /* */
|
|
52 |
- /* size :: The requested size in bytes. */
|
|
53 |
- /* */
|
|
54 |
- /* <Return> */
|
|
55 |
- /* The address of newly allocated block. */
|
|
56 |
- /* */
|
|
34 |
+ /**************************************************************************
|
|
35 |
+ *
|
|
36 |
+ * MEMORY MANAGEMENT INTERFACE
|
|
37 |
+ *
|
|
38 |
+ */
|
|
39 |
+ |
|
40 |
+ |
|
41 |
+ /**************************************************************************
|
|
42 |
+ *
|
|
43 |
+ * It is not necessary to do any error checking for the
|
|
44 |
+ * allocation-related functions. This will be done by the higher level
|
|
45 |
+ * routines like ft_mem_alloc() or ft_mem_realloc().
|
|
46 |
+ *
|
|
47 |
+ */
|
|
48 |
+ |
|
49 |
+ |
|
50 |
+ /**************************************************************************
|
|
51 |
+ *
|
|
52 |
+ * @Function:
|
|
53 |
+ * ft_alloc
|
|
54 |
+ *
|
|
55 |
+ * @Description:
|
|
56 |
+ * The memory allocation function.
|
|
57 |
+ *
|
|
58 |
+ * @Input:
|
|
59 |
+ * memory ::
|
|
60 |
+ * A pointer to the memory object.
|
|
61 |
+ *
|
|
62 |
+ * size ::
|
|
63 |
+ * The requested size in bytes.
|
|
64 |
+ *
|
|
65 |
+ * @Return:
|
|
66 |
+ * The address of newly allocated block.
|
|
67 |
+ */
|
|
57 | 68 |
FT_CALLBACK_DEF( void* )
|
58 | 69 |
ft_alloc( FT_Memory memory,
|
59 | 70 |
long size )
|
... | ... | @@ -64,26 +75,30 @@ |
64 | 75 |
}
|
65 | 76 |
|
66 | 77 |
|
67 |
- /*************************************************************************/
|
|
68 |
- /* */
|
|
69 |
- /* <Function> */
|
|
70 |
- /* ft_realloc */
|
|
71 |
- /* */
|
|
72 |
- /* <Description> */
|
|
73 |
- /* The memory reallocation function. */
|
|
74 |
- /* */
|
|
75 |
- /* <Input> */
|
|
76 |
- /* memory :: A pointer to the memory object. */
|
|
77 |
- /* */
|
|
78 |
- /* cur_size :: The current size of the allocated memory block. */
|
|
79 |
- /* */
|
|
80 |
- /* new_size :: The newly requested size in bytes. */
|
|
81 |
- /* */
|
|
82 |
- /* block :: The current address of the block in memory. */
|
|
83 |
- /* */
|
|
84 |
- /* <Return> */
|
|
85 |
- /* The address of the reallocated memory block. */
|
|
86 |
- /* */
|
|
78 |
+ /**************************************************************************
|
|
79 |
+ *
|
|
80 |
+ * @Function:
|
|
81 |
+ * ft_realloc
|
|
82 |
+ *
|
|
83 |
+ * @Description:
|
|
84 |
+ * The memory reallocation function.
|
|
85 |
+ *
|
|
86 |
+ * @Input:
|
|
87 |
+ * memory ::
|
|
88 |
+ * A pointer to the memory object.
|
|
89 |
+ *
|
|
90 |
+ * cur_size ::
|
|
91 |
+ * The current size of the allocated memory block.
|
|
92 |
+ *
|
|
93 |
+ * new_size ::
|
|
94 |
+ * The newly requested size in bytes.
|
|
95 |
+ *
|
|
96 |
+ * block ::
|
|
97 |
+ * The current address of the block in memory.
|
|
98 |
+ *
|
|
99 |
+ * @Return:
|
|
100 |
+ * The address of the reallocated memory block.
|
|
101 |
+ */
|
|
87 | 102 |
FT_CALLBACK_DEF( void* )
|
88 | 103 |
ft_realloc( FT_Memory memory,
|
89 | 104 |
long cur_size,
|
... | ... | @@ -97,19 +112,21 @@ |
97 | 112 |
}
|
98 | 113 |
|
99 | 114 |
|
100 |
- /*************************************************************************/
|
|
101 |
- /* */
|
|
102 |
- /* <Function> */
|
|
103 |
- /* ft_free */
|
|
104 |
- /* */
|
|
105 |
- /* <Description> */
|
|
106 |
- /* The memory release function. */
|
|
107 |
- /* */
|
|
108 |
- /* <Input> */
|
|
109 |
- /* memory :: A pointer to the memory object. */
|
|
110 |
- /* */
|
|
111 |
- /* block :: The address of block in memory to be freed. */
|
|
112 |
- /* */
|
|
115 |
+ /**************************************************************************
|
|
116 |
+ *
|
|
117 |
+ * @Function:
|
|
118 |
+ * ft_free
|
|
119 |
+ *
|
|
120 |
+ * @Description:
|
|
121 |
+ * The memory release function.
|
|
122 |
+ *
|
|
123 |
+ * @Input:
|
|
124 |
+ * memory ::
|
|
125 |
+ * A pointer to the memory object.
|
|
126 |
+ *
|
|
127 |
+ * block ::
|
|
128 |
+ * The address of block in memory to be freed.
|
|
129 |
+ */
|
|
113 | 130 |
FT_CALLBACK_DEF( void )
|
114 | 131 |
ft_free( FT_Memory memory,
|
115 | 132 |
void* block )
|
... | ... | @@ -120,19 +137,19 @@ |
120 | 137 |
}
|
121 | 138 |
|
122 | 139 |
|
123 |
- /*************************************************************************/
|
|
124 |
- /* */
|
|
125 |
- /* RESOURCE MANAGEMENT INTERFACE */
|
|
126 |
- /* */
|
|
127 |
- /*************************************************************************/
|
|
140 |
+ /**************************************************************************
|
|
141 |
+ *
|
|
142 |
+ * RESOURCE MANAGEMENT INTERFACE
|
|
143 |
+ *
|
|
144 |
+ */
|
|
128 | 145 |
|
129 | 146 |
|
130 |
- /*************************************************************************/
|
|
131 |
- /* */
|
|
132 |
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
133 |
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
134 |
- /* messages during execution. */
|
|
135 |
- /* */
|
|
147 |
+ /**************************************************************************
|
|
148 |
+ *
|
|
149 |
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
|
|
150 |
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
|
|
151 |
+ * messages during execution.
|
|
152 |
+ */
|
|
136 | 153 |
#undef FT_COMPONENT
|
137 | 154 |
#define FT_COMPONENT io
|
138 | 155 |
|
... | ... | @@ -141,17 +158,17 @@ |
141 | 158 |
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
|
142 | 159 |
|
143 | 160 |
|
144 |
- /*************************************************************************/
|
|
145 |
- /* */
|
|
146 |
- /* <Function> */
|
|
147 |
- /* ft_close_stream_by_munmap */
|
|
148 |
- /* */
|
|
149 |
- /* <Description> */
|
|
150 |
- /* The function to close a stream which is opened by mmap. */
|
|
151 |
- /* */
|
|
152 |
- /* <Input> */
|
|
153 |
- /* stream :: A pointer to the stream object. */
|
|
154 |
- /* */
|
|
161 |
+ /**************************************************************************
|
|
162 |
+ *
|
|
163 |
+ * @Function:
|
|
164 |
+ * ft_close_stream_by_munmap
|
|
165 |
+ *
|
|
166 |
+ * @Description:
|
|
167 |
+ * The function to close a stream which is opened by mmap.
|
|
168 |
+ *
|
|
169 |
+ * @Input:
|
|
170 |
+ * stream :: A pointer to the stream object.
|
|
171 |
+ */
|
|
155 | 172 |
FT_CALLBACK_DEF( void )
|
156 | 173 |
ft_close_stream_by_munmap( FT_Stream stream )
|
157 | 174 |
{
|
... | ... | @@ -163,17 +180,17 @@ |
163 | 180 |
}
|
164 | 181 |
|
165 | 182 |
|
166 |
- /*************************************************************************/
|
|
167 |
- /* */
|
|
168 |
- /* <Function> */
|
|
169 |
- /* ft_close_stream_by_free */
|
|
170 |
- /* */
|
|
171 |
- /* <Description> */
|
|
172 |
- /* The function to close a stream which is created by ft_alloc. */
|
|
173 |
- /* */
|
|
174 |
- /* <Input> */
|
|
175 |
- /* stream :: A pointer to the stream object. */
|
|
176 |
- /* */
|
|
183 |
+ /**************************************************************************
|
|
184 |
+ *
|
|
185 |
+ * @Function:
|
|
186 |
+ * ft_close_stream_by_free
|
|
187 |
+ *
|
|
188 |
+ * @Description:
|
|
189 |
+ * The function to close a stream which is created by ft_alloc.
|
|
190 |
+ *
|
|
191 |
+ * @Input:
|
|
192 |
+ * stream :: A pointer to the stream object.
|
|
193 |
+ */
|
|
177 | 194 |
FT_CALLBACK_DEF( void )
|
178 | 195 |
ft_close_stream_by_free( FT_Stream stream )
|
179 | 196 |
{
|
... | ... | @@ -191,9 +208,10 @@ |
191 | 208 |
FT_Stream_Open( FT_Stream stream,
|
192 | 209 |
const char* filepathname )
|
193 | 210 |
{
|
194 |
- HANDLE file;
|
|
195 |
- HANDLE fm;
|
|
196 |
- LARGE_INTEGER size;
|
|
211 |
+ HANDLE file;
|
|
212 |
+ HANDLE fm;
|
|
213 |
+ LARGE_INTEGER size;
|
|
214 |
+ |
|
197 | 215 |
|
198 | 216 |
if ( !stream )
|
199 | 217 |
return FT_THROW( Invalid_Stream_Handle );
|
... | ... | @@ -201,14 +219,14 @@ |
201 | 219 |
/* open the file */
|
202 | 220 |
file = CreateFileA( filepathname, GENERIC_READ, FILE_SHARE_READ, NULL,
|
203 | 221 |
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
|
204 |
- if (file == INVALID_HANDLE_VALUE)
|
|
222 |
+ if ( file == INVALID_HANDLE_VALUE )
|
|
205 | 223 |
{
|
206 | 224 |
FT_ERROR(( "FT_Stream_Open:" ));
|
207 | 225 |
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
208 | 226 |
return FT_THROW( Cannot_Open_Resource );
|
209 | 227 |
}
|
210 | 228 |
|
211 |
- if ( GetFileSizeEx(file, &size) == FALSE )
|
|
229 |
+ if ( GetFileSizeEx( file, &size ) == FALSE )
|
|
212 | 230 |
{
|
213 | 231 |
FT_ERROR(( "FT_Stream_Open:" ));
|
214 | 232 |
FT_ERROR(( " could not retrieve size of file `%s'\n", filepathname ));
|
... | ... | @@ -229,8 +247,8 @@ |
229 | 247 |
goto Fail_Open;
|
230 | 248 |
}
|
231 | 249 |
|
232 |
- fm = CreateFileMapping(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
|
233 |
- if (fm == NULL)
|
|
250 |
+ fm = CreateFileMapping( file, NULL, PAGE_READONLY, 0, 0, NULL );
|
|
251 |
+ if ( fm == NULL )
|
|
234 | 252 |
{
|
235 | 253 |
FT_ERROR(( "FT_Stream_Open: can not map file\n" ));
|
236 | 254 |
goto Fail_Open;
|
... | ... | @@ -241,14 +259,17 @@ |
241 | 259 |
/* a size greater than LONG_MAX */
|
242 | 260 |
stream->size = size.LowPart;
|
243 | 261 |
stream->pos = 0;
|
244 |
- stream->base = (unsigned char *)MapViewOfFile(fm, FILE_MAP_READ, 0, 0, 0);
|
|
262 |
+ stream->base = (unsigned char *)
|
|
263 |
+ MapViewOfFile( fm, FILE_MAP_READ, 0, 0, 0 );
|
|
264 |
+ |
|
265 |
+ CloseHandle( fm );
|
|
245 | 266 |
|
246 |
- CloseHandle(fm);
|
|
247 | 267 |
if ( stream->base != NULL )
|
248 | 268 |
stream->close = ft_close_stream_by_munmap;
|
249 | 269 |
else
|
250 | 270 |
{
|
251 |
- DWORD total_read_count;
|
|
271 |
+ DWORD total_read_count;
|
|
272 |
+ |
|
252 | 273 |
|
253 | 274 |
FT_ERROR(( "FT_Stream_Open:" ));
|
254 | 275 |
FT_ERROR(( " could not `mmap' file `%s'\n", filepathname ));
|
... | ... | @@ -265,7 +286,8 @@ |
265 | 286 |
total_read_count = 0;
|
266 | 287 |
do
|
267 | 288 |
{
|
268 |
- DWORD read_count;
|
|
289 |
+ DWORD read_count;
|
|
290 |
+ |
|
269 | 291 |
|
270 | 292 |
if ( ReadFile( file,
|
271 | 293 |
stream->base + total_read_count,
|