aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c
index ed5d6b5099f..6ef0782ca1b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -735,6 +735,22 @@ xmalloc (size_t size)
735 return val; 735 return val;
736} 736}
737 737
738/* Like the above, but zeroes out the memory just allocated. */
739
740void *
741xzalloc (size_t size)
742{
743 void *val;
744
745 MALLOC_BLOCK_INPUT;
746 val = malloc (size);
747 MALLOC_UNBLOCK_INPUT;
748
749 if (!val && size)
750 memory_full (size);
751 memset (val, 0, size);
752 return val;
753}
738 754
739/* Like realloc but check for no memory and block interrupt input.. */ 755/* Like realloc but check for no memory and block interrupt input.. */
740 756
@@ -867,7 +883,7 @@ char *
867xstrdup (const char *s) 883xstrdup (const char *s)
868{ 884{
869 size_t len = strlen (s) + 1; 885 size_t len = strlen (s) + 1;
870 char *p = (char *) xmalloc (len); 886 char *p = xmalloc (len);
871 memcpy (p, s, len); 887 memcpy (p, s, len);
872 return p; 888 return p;
873} 889}
@@ -3881,7 +3897,7 @@ mem_insert (void *start, void *end, enum mem_type type)
3881 if (x == NULL) 3897 if (x == NULL)
3882 abort (); 3898 abort ();
3883#else 3899#else
3884 x = (struct mem_node *) xmalloc (sizeof *x); 3900 x = xmalloc (sizeof *x);
3885#endif 3901#endif
3886 x->start = start; 3902 x->start = start;
3887 x->end = end; 3903 x->end = end;
@@ -5047,7 +5063,7 @@ pure_alloc (size_t size, int type)
5047 /* Don't allocate a large amount here, 5063 /* Don't allocate a large amount here,
5048 because it might get mmap'd and then its address 5064 because it might get mmap'd and then its address
5049 might not be usable. */ 5065 might not be usable. */
5050 purebeg = (char *) xmalloc (10000); 5066 purebeg = xmalloc (10000);
5051 pure_size = 10000; 5067 pure_size = 10000;
5052 pure_bytes_used_before_overflow += pure_bytes_used - size; 5068 pure_bytes_used_before_overflow += pure_bytes_used - size;
5053 pure_bytes_used = 0; 5069 pure_bytes_used = 0;