* src/alloc.c (record_xmalloc): Remove. All uses changed.
* src/lisp.h (SAFE_ALLOCA, SAFE_NALLOCA, SAFE_ALLOCA_LISP): Use normal
allocation functions and don't explicitly free memory. Remove all
references to variables defined by these macros.
(USE_SAFE_ALLOCA, SAFE_FREE): Now no-ops.
if (putenv ((char *) string) != 0)
memory_full (0);
}
-
-/* Return a newly allocated memory block of SIZE bytes, remembering
- to free it when unwinding. */
-void *
-record_xmalloc (size_t size)
-{
- void *p = xmalloc (size);
- record_unwind_protect_ptr (xfree, p);
- return p;
-}
\f
/***********************************************************************
Interval Allocation
Lisp_Object volatile coding_systems_volatile = coding_systems;
Lisp_Object volatile current_dir_volatile = current_dir;
bool volatile display_p_volatile = display_p;
- bool volatile sa_must_free_volatile = sa_must_free;
int volatile fd_error_volatile = fd_error;
int volatile filefd_volatile = filefd;
ptrdiff_t volatile count_volatile = count;
- ptrdiff_t volatile sa_count_volatile = sa_count;
char **volatile new_argv_volatile = new_argv;
int volatile callproc_fd_volatile[CALLPROC_FDS];
for (i = 0; i < CALLPROC_FDS; i++)
coding_systems = coding_systems_volatile;
current_dir = current_dir_volatile;
display_p = display_p_volatile;
- sa_must_free = sa_must_free_volatile;
fd_error = fd_error_volatile;
filefd = filefd_volatile;
count = count_volatile;
- sa_count = sa_count_volatile;
new_argv = new_argv_volatile;
for (i = 0; i < CALLPROC_FDS; i++)
set_unwind_protect_ptr (count, fclose_unwind, fp);
unbind_to (count + 1, Qnil);
- /* Use record_xmalloc, as `charset_map_entries' is
- large (larger than MAX_ALLOCA). */
- head = record_xmalloc (sizeof *head);
+ /* Use record, as `charset_map_entries' is large (larger than
+ MAX_ALLOCA). */
+ head = xmalloc (sizeof *head);
entries = head;
memset (entries, 0, sizeof (struct charset_map_entries));
if (n_entries == 0x10000)
{
- entries->next = record_xmalloc (sizeof *entries->next);
+ entries->next = xmalloc (sizeof *entries->next);
entries = entries->next;
memset (entries, 0, sizeof (struct charset_map_entries));
n_entries = 0;
ptrdiff_t bufsize = sizeof initial_buffer;
ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
char *p;
- ptrdiff_t buf_save_value_index IF_LINT (= 0);
char *format, *end, *format_start;
ptrdiff_t formatlen, nchars;
/* True if the format is multibyte. */
if (buf == initial_buffer)
{
buf = xmalloc_atomic (bufsize);
- sa_must_free = true;
- buf_save_value_index = SPECPDL_INDEX ();
- record_unwind_protect_ptr (xfree, buf);
memcpy (buf, initial_buffer, used);
}
else
{
buf = xrealloc (buf, bufsize);
- set_unwind_protect_ptr (buf_save_value_index, xfree, buf);
}
p = buf + used;
enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 };
-extern void *record_xmalloc (size_t) ATTRIBUTE_ALLOC_SIZE ((1));
-
-#define USE_SAFE_ALLOCA \
- ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = false
+#define USE_SAFE_ALLOCA ((void) 0)
/* SAFE_ALLOCA allocates a simple buffer. */
#define SAFE_ALLOCA(size) ((size) < MAX_ALLOCA \
? alloca (size) \
- : (sa_must_free = true, record_xmalloc (size)))
+ : xmalloc (size))
/* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER *
NITEMS items, each of the same type as *BUF. MULTIPLIER must
if ((nitems) <= MAX_ALLOCA / sizeof *(buf) / (multiplier)) \
(buf) = alloca (sizeof *(buf) * (multiplier) * (nitems)); \
else \
- { \
- (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \
- sa_must_free = true; \
- record_unwind_protect_ptr (xfree, buf); \
- } \
- } while (false)
+ (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \
+ } while (0)
/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
-#define SAFE_FREE() \
- do { \
- if (sa_must_free) { \
- sa_must_free = false; \
- unbind_to (sa_count, Qnil); \
- } \
- } while (false)
-
+#define SAFE_FREE() ((void) 0)
/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */
if ((nelt) < MAX_ALLOCA / word_size) \
(buf) = alloca ((nelt) * word_size); \
else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / word_size) \
- { \
- Lisp_Object arg_; \
- (buf) = xmalloc ((nelt) * word_size); \
- arg_ = make_save_memory (buf, nelt); \
- sa_must_free = true; \
- record_unwind_protect (free_save_value, arg_); \
- } \
+ buf = xmalloc ((nelt) * word_size); \
else \
memory_full (SIZE_MAX); \
} while (false)