aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2014-06-27 11:31:20 +0300
committerEli Zaretskii2014-06-27 11:31:20 +0300
commit4f1e55070b5f144e37a35ac82b2d88077c0290ea (patch)
tree4fcdb0332dab1d2acbdcf7adad935aa45ef02dd5
parentd9824c5167e8cc22da66c1bcd6bdcd450ab7775e (diff)
downloademacs-4f1e55070b5f144e37a35ac82b2d88077c0290ea.tar.gz
emacs-4f1e55070b5f144e37a35ac82b2d88077c0290ea.zip
src/w32heap.c: Minor formatting and whitespace changes.
-rw-r--r--src/w32heap.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/w32heap.c b/src/w32heap.c
index 94ba3428794..c431b87e0c2 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -200,12 +200,11 @@ dumped_data_commit (PVOID Base, PVOID *CommitAddress, PSIZE_T CommitSize)
200 as requests arrive. */ 200 as requests arrive. */
201 *CommitAddress = data_region_base + committed; 201 *CommitAddress = data_region_base + committed;
202 committed += *CommitSize; 202 committed += *CommitSize;
203 /* Check that the private heap area does not overlap the big chunks area. */
203 if (((unsigned char *)(*CommitAddress)) + *CommitSize >= bc_limit) 204 if (((unsigned char *)(*CommitAddress)) + *CommitSize >= bc_limit)
204 { 205 {
205 /* Check that the private heap area does not overlap the big 206 fprintf (stderr,
206 chunks area. */ 207 "dumped_data_commit: memory exhausted.\nEnlarge dumped_data[]!\n");
207 fprintf(stderr,
208 "dumped_data_commit: memory exhausted.\nEnlarge dumped_data[]!\n");
209 exit (-1); 208 exit (-1);
210 } 209 }
211 return 0; 210 return 0;
@@ -243,18 +242,20 @@ init_heap (void)
243 data_region_end = data_region_base; 242 data_region_end = data_region_base;
244 243
245 /* Create the private heap. */ 244 /* Create the private heap. */
246 heap = HeapCreate(0, 0, 0); 245 heap = HeapCreate (0, 0, 0);
247 246
248#ifndef _W64 247#ifndef _W64
249 /* Set the low-fragmentation heap for OS before Vista. */ 248 /* Set the low-fragmentation heap for OS before Vista. */
250 HMODULE hm_kernel32dll = LoadLibrary("kernel32.dll"); 249 HMODULE hm_kernel32dll = LoadLibrary ("kernel32.dll");
251 HeapSetInformation_Proc s_pfn_Heap_Set_Information = (HeapSetInformation_Proc) GetProcAddress(hm_kernel32dll, "HeapSetInformation"); 250 HeapSetInformation_Proc s_pfn_Heap_Set_Information = (HeapSetInformation_Proc) GetProcAddress (hm_kernel32dll, "HeapSetInformation");
252 if (s_pfn_Heap_Set_Information != NULL) 251 if (s_pfn_Heap_Set_Information != NULL)
253 if (s_pfn_Heap_Set_Information ((PVOID) heap, 252 {
254 HeapCompatibilityInformation, 253 if (s_pfn_Heap_Set_Information ((PVOID) heap,
255 &enable_lfh, sizeof(enable_lfh)) == 0) 254 HeapCompatibilityInformation,
256 DebPrint (("Enabling Low Fragmentation Heap failed: error %ld\n", 255 &enable_lfh, sizeof(enable_lfh)) == 0)
257 GetLastError ())); 256 DebPrint (("Enabling Low Fragmentation Heap failed: error %ld\n",
257 GetLastError ()));
258 }
258#endif 259#endif
259 260
260 the_malloc_fn = malloc_after_dump; 261 the_malloc_fn = malloc_after_dump;
@@ -271,7 +272,7 @@ init_heap (void)
271 = (RtlCreateHeap_Proc) GetProcAddress (hm_ntdll, "RtlCreateHeap"); 272 = (RtlCreateHeap_Proc) GetProcAddress (hm_ntdll, "RtlCreateHeap");
272 /* Specific parameters for the private heap. */ 273 /* Specific parameters for the private heap. */
273 RTL_HEAP_PARAMETERS params; 274 RTL_HEAP_PARAMETERS params;
274 ZeroMemory(&params, sizeof(params)); 275 ZeroMemory (&params, sizeof(params));
275 params.Length = sizeof(RTL_HEAP_PARAMETERS); 276 params.Length = sizeof(RTL_HEAP_PARAMETERS);
276 277
277 data_region_base = (unsigned char *)ROUND_UP (dumped_data, 0x1000); 278 data_region_base = (unsigned char *)ROUND_UP (dumped_data, 0x1000);
@@ -284,6 +285,11 @@ init_heap (void)
284 params.CommitRoutine = &dumped_data_commit; 285 params.CommitRoutine = &dumped_data_commit;
285 286
286 /* Create the private heap. */ 287 /* Create the private heap. */
288 if (s_pfn_Rtl_Create_Heap == NULL)
289 {
290 fprintf (stderr, "Cannot build Emacs without RtlCreateHeap being available; exiting.\n");
291 exit (-1);
292 }
287 heap = s_pfn_Rtl_Create_Heap (0, data_region_base, 0, 0, NULL, &params); 293 heap = s_pfn_Rtl_Create_Heap (0, data_region_base, 0, 0, NULL, &params);
288 the_malloc_fn = malloc_before_dump; 294 the_malloc_fn = malloc_before_dump;
289 the_realloc_fn = realloc_before_dump; 295 the_realloc_fn = realloc_before_dump;
@@ -358,8 +364,8 @@ malloc_before_dump (size_t size)
358 array. */ 364 array. */
359 if (blocks_number >= MAX_BLOCKS) 365 if (blocks_number >= MAX_BLOCKS)
360 { 366 {
361 fprintf(stderr, 367 fprintf (stderr,
362 "malloc_before_dump: no more big chunks available.\nEnlarge MAX_BLOCKS!\n"); 368 "malloc_before_dump: no more big chunks available.\nEnlarge MAX_BLOCKS!\n");
363 exit (-1); 369 exit (-1);
364 } 370 }
365 bc_limit -= size; 371 bc_limit -= size;
@@ -369,11 +375,11 @@ malloc_before_dump (size_t size)
369 blocks[blocks_number].size = size; 375 blocks[blocks_number].size = size;
370 blocks[blocks_number].occupied = TRUE; 376 blocks[blocks_number].occupied = TRUE;
371 blocks_number++; 377 blocks_number++;
378 /* Check that areas do not overlap. */
372 if (bc_limit < dumped_data + committed) 379 if (bc_limit < dumped_data + committed)
373 { 380 {
374 /* Check that areas do not overlap. */ 381 fprintf (stderr,
375 fprintf(stderr, 382 "malloc_before_dump: memory exhausted.\nEnlarge dumped_data[]!\n");
376 "malloc_before_dump: memory exhausted.\nEnlarge dumped_data[]!\n");
377 exit (-1); 383 exit (-1);
378 } 384 }
379 } 385 }