emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2b6d702: Fix the MS-Windows build broken by "Let the OS clear lar


From: Eli Zaretskii
Subject: master 2b6d702: Fix the MS-Windows build broken by "Let the OS clear large new objects"
Date: Fri, 3 Jan 2020 11:28:48 -0500 (EST)

branch: master
commit 2b6d702e5d2d572640c6bcd43f54138bacbe7ac8
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix the MS-Windows build broken by "Let the OS clear large new objects"
    
    * src/w32heap.c (sys_calloc): New function, implements calloc
    in terms of our private implementations of malloc.
    
    * nt/inc/ms-w32.h (calloc): Redirect to sys_calloc.
---
 nt/inc/ms-w32.h |  3 +++
 src/w32heap.c   | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index 6d20c95..3b1d3ff 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -499,6 +499,8 @@ extern void *malloc_after_dump_9x(size_t);
 extern void *realloc_after_dump_9x(void *, size_t);
 extern void free_after_dump_9x(void *);
 
+extern void *sys_calloc(size_t, size_t);
+
 extern malloc_fn the_malloc_fn;
 extern realloc_fn the_realloc_fn;
 extern free_fn the_free_fn;
@@ -506,6 +508,7 @@ extern free_fn the_free_fn;
 #define malloc(size) (*the_malloc_fn)(size)
 #define free(ptr)   (*the_free_fn)(ptr)
 #define realloc(ptr, size) (*the_realloc_fn)(ptr, size)
+#define calloc(num, size) sys_calloc(num, size)
 
 #endif
 
diff --git a/src/w32heap.c b/src/w32heap.c
index 3a6c780..ececc73 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -597,6 +597,16 @@ free_after_dump_9x (void *ptr)
     }
 }
 
+void *
+sys_calloc (size_t number, size_t size)
+{
+  size_t nbytes = number * size;
+  void *ptr = (*the_malloc_fn) (nbytes);
+  if (ptr)
+    memset (ptr, 0, nbytes);
+  return ptr;
+}
+
 #if defined HAVE_UNEXEC && defined ENABLE_CHECKING
 void
 report_temacs_memory_usage (void)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]