ptrdiff_t size;
eassert (s);
size = strlen (s) + 1;
- return memcpy (xmalloc (size), s, size);
+ return memcpy (xmalloc_atomic (size), s, size);
}
/* Like above, but duplicates Lisp string to C string. */
xlispstrdup (Lisp_Object string)
{
ptrdiff_t size = SBYTES (string) + 1;
- return memcpy (xmalloc (size), SSDATA (string), size);
+ return memcpy (xmalloc_atomic (size), SSDATA (string), size);
}
/* Assign to *PTR a copy of STRING, freeing any storage *PTR formerly
make_float (double float_value)
{
register Lisp_Object val;
- XSETFLOAT (val, xmalloc (sizeof (struct Lisp_Float)));
+ XSETFLOAT (val, xmalloc_atomic (sizeof (struct Lisp_Float)));
XFLOAT_INIT (val, float_value);
return val;
}
bool enough_free_memory = 0;
if (SPARE_MEMORY < nbytes)
{
- void *p = xmalloc_unsafe (SPARE_MEMORY);
+ void *p = xmalloc_atomic_unsafe (SPARE_MEMORY);
if (p)
{
xfree (p);
refill_memory_reserve (void)
{
if (spare_memory == NULL)
- spare_memory = xmalloc_unsafe (SPARE_MEMORY);
+ spare_memory = xmalloc_atomic_unsafe (SPARE_MEMORY);
if (spare_memory)
Vmemory_full = Qnil;
#elif defined REL_ALLOC
p = r_alloc ((void **) &b->text->beg, nbytes);
#else
- p = xmalloc (nbytes);
+ p = xmalloc_atomic (nbytes);
#endif
if (p == NULL)
outbufsize = (ccl.buf_magnification
? str_bytes * ccl.buf_magnification + 256
: str_bytes + 256);
- outp = outbuf = xmalloc (outbufsize);
+ outp = outbuf = xmalloc_atomic (outbufsize);
consumed_chars = consumed_bytes = 0;
produced_chars = 0;
if (! charset.code_linear_p)
{
- charset.code_space_mask = xzalloc (256);
+ charset.code_space_mask = xzalloc_atomic (256);
for (i = 0; i < 4; i++)
for (j = charset.code_space[i * 4]; j <= charset.code_space[i * 4 + 1];
j++)
{
ptrdiff_t dst_bytes = max (1, coding->src_chars);
coding->dst_object = Qnil;
- coding->destination = xmalloc (dst_bytes);
+ coding->destination = xmalloc_atomic (dst_bytes);
coding->dst_bytes = dst_bytes;
coding->dst_multibyte = 0;
}
cmp->method = method;
cmp->hash_index = hash_index;
cmp->glyph_len = glyph_len;
- cmp->offsets = xnmalloc (glyph_len, 2 * sizeof *cmp->offsets);
+ cmp->offsets = xnmalloc_atomic (glyph_len, 2 * sizeof *cmp->offsets);
cmp->font = NULL;
if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS)
keymap = Voverriding_local_map;
bsize = SBYTES (string);
- bufp = buf = xmalloc (bsize);
+ bufp = buf = xmalloc_atomic (bsize);
strp = SDATA (string);
while (strp < SDATA (string) + SBYTES (string))
{
if (big_buffer)
xfree (big_buffer);
- big_buffer = xmalloc (size_bound);
+ big_buffer = xmalloc_atomic (size_bound);
sprintf_buffer = big_buffer;
size_allocated = size_bound;
}
if (buf == initial_buffer)
{
- buf = xmalloc (bufsize);
+ buf = xmalloc_atomic (bufsize);
sa_must_free = true;
buf_save_value_index = SPECPDL_INDEX ();
record_unwind_protect_ptr (xfree, buf);
0 for an option that takes no arguments,
1 for an option that takes one argument, etc.
-1 for an ordinary non-option argument. */
- int *options = xnmalloc (argc, sizeof *options);
- int *priority = xnmalloc (argc, sizeof *priority);
+ int *options = xnmalloc_atomic (argc, sizeof *options);
+ int *priority = xnmalloc_atomic (argc, sizeof *priority);
int to = 1;
int incoming_used = 1;
int from;
if (STRING_MULTIBYTE (string))
{
ptrdiff_t chars = SCHARS (string);
- unsigned char *str = xmalloc (chars);
+ unsigned char *str = xmalloc_atomic (chars);
ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars);
if (converted < chars)
spec->features[i] =
(min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len)
? 0
- : xmalloc_unsafe (XINT (len) * sizeof *spec->features[i]));
+ : xmalloc_atomic_unsafe (XINT (len) * sizeof *spec->features[i]));
if (! spec->features[i])
{
if (i > 0 && spec->features[0])
len = strlen (str);
if ((min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4 < nr_bad)
memory_full (SIZE_MAX);
- up = utf8_str = xmalloc (len + nr_bad * 4 + 1);
+ up = utf8_str = xmalloc_atomic (len + nr_bad * 4 + 1);
p = (unsigned char *)str;
while (! (cp = g_locale_to_utf8 ((char *)p, -1, &bytes_read,
}
/* Allocate image raster. */
- (*ximg)->data = xmalloc ((*ximg)->bytes_per_line * height);
+ (*ximg)->data = xmalloc_atomic ((*ximg)->bytes_per_line * height);
/* Allocate a pixmap of the same size. */
*pixmap = XCreatePixmap (display, window, width, height, depth);
}
bytes_per_line = (*width + 7) / 8 + padding_p;
nbytes = bytes_per_line * *height;
- p = *data = xmalloc (nbytes);
+ p = *data = xmalloc_atomic (nbytes);
if (v10)
{
#endif /* HAVE_NTGUI */
/* Remember allocated colors. */
- img->colors = xnmalloc (attrs.nalloc_pixels, sizeof *img->colors);
+ img->colors = xnmalloc_atomic (attrs.nalloc_pixels,
+ sizeof *img->colors);
img->ncolors = attrs.nalloc_pixels;
for (i = 0; i < attrs.nalloc_pixels; ++i)
{
}
else
{
- colors = xmalloc (ct_colors_allocated * sizeof *colors);
+ colors = xmalloc_atomic (ct_colors_allocated * sizeof *colors);
*n = ct_colors_allocated;
for (i = j = 0; i < CT_SIZE; ++i)
if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height
|| min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes)
memory_full (SIZE_MAX);
- c->pixels = pixels = xmalloc (sizeof *pixels * row_bytes * height);
- c->rows = rows = xmalloc (height * sizeof *rows);
+ c->pixels = pixels = xmalloc_atomic (sizeof *pixels * row_bytes * height);
+ c->rows = rows = xmalloc_atomic (height * sizeof *rows);
for (i = 0; i < height; ++i)
rows[i] = pixels + i * row_bytes;
return 0;
}
- buf = xmalloc (sizeof *buf * width * height);
+ buf = xmalloc_atomic (sizeof *buf * width * height);
rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0);
const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : "";
ptrdiff_t max_lbl =
2 * max (0, min (tool_bar_max_label_size, STRING_BYTES_BOUND / 2));
- char *buf = xmalloc (max_lbl + 1);
+ char *buf = xmalloc_atomic (max_lbl + 1);
Lisp_Object new_lbl;
ptrdiff_t caption_len = strlen (capt);
if (saved_doc_string_size == 0)
{
- saved_doc_string = xmalloc (nskip + extra);
+ saved_doc_string = xmalloc_atomic (nskip + extra);
saved_doc_string_size = nskip + extra;
}
if (nskip > saved_doc_string_size)
DEFSYM (Qvariable_documentation, "variable-documentation");
- read_buffer = xmalloc (size);
+ read_buffer = xmalloc_atomic (size);
read_buffer_size = size;
}
\f
val = Qnil;
size = 100;
len = 0;
- line = xmalloc (size);
+ line = xmalloc_atomic (size);
while ((c = getchar ()) != '\n')
{
else \
{ \
int new_size = 1000; \
- print_buffer = xmalloc (new_size); \
+ print_buffer = xmalloc_atomic (new_size); \
print_buffer_size = new_size; \
free_print_buffer = 1; \
} \
substed_alloc_size = (length <= (STRING_BYTES_BOUND - 100) / 2
? length * 2 + 100
: STRING_BYTES_BOUND);
- substed = xmalloc (substed_alloc_size);
+ substed = xmalloc_atomic (substed_alloc_size);
substed_len = 0;
/* Go thru NEWTEXT, producing the actual text to insert in
for (i = 0; i < REGEXP_CACHE_SIZE; ++i)
{
searchbufs[i].buf.allocated = 100;
- searchbufs[i].buf.buffer = xmalloc (100);
+ searchbufs[i].buf.buffer = xmalloc_atomic (100);
searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
searchbufs[i].regexp = Qnil;
searchbufs[i].whitespace_regexp = Qnil;
p = ptr;
while ((c = *p++) && c != ':' && c != '\n')
;
- ret = xmalloc (p - ptr + 1);
+ ret = xmalloc_atomic (p - ptr + 1);
}
else
ret = *area;
if (!bp)
{
malloc_size = 1 + strlen (term);
- bp = xmalloc (malloc_size);
+ bp = xmalloc_atomic (malloc_size);
}
strcpy (bp, term);
goto ret;
buf.size = BUFSIZE;
/* Add 1 to size to ensure room for terminating null. */
- buf.beg = xmalloc (buf.size + 1);
+ buf.beg = xmalloc_atomic (buf.size + 1);
term = indirect ? indirect : (char *)name;
if (!bp)
{
malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;
- bp = xmalloc (malloc_size);
+ bp = xmalloc_atomic (malloc_size);
}
tc_search_point = bp1 = bp;
if (outlen == 0)
{
outlen = len + 40;
- new = xmalloc (outlen);
+ new = xmalloc_atomic (outlen);
memcpy (new, outstring, offset);
}
else
/* Allocate the buffer for frame titles.
Also used for `format-mode-line'. */
int size = 100;
- mode_line_noprop_buf = xmalloc (size);
+ mode_line_noprop_buf = xmalloc_atomic (size);
mode_line_noprop_buf_end = mode_line_noprop_buf + size;
mode_line_noprop_ptr = mode_line_noprop_buf;
mode_line_target = MODE_LINE_DISPLAY;
coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK);
/* We suppress producing escape sequences for composition. */
coding.common_flags &= ~CODING_ANNOTATION_MASK;
- coding.destination = xnmalloc (SCHARS (string), 2);
+ coding.destination = xnmalloc_atomic (SCHARS (string), 2);
coding.dst_bytes = SCHARS (string) * 2;
encode_coding_object (&coding, string, 0, 0,
SCHARS (string), SBYTES (string), Qnil);
if (xic_default_fontset == base_fontname)
{
/* There is no base font name, use the default. */
- fontsetname = xmalloc (strlen (base_fontname) + 2);
+ fontsetname = xmalloc_atomic (strlen (base_fontname) + 2);
strcpy (fontsetname, base_fontname);
}
else
/* As the font name doesn't conform to XLFD, we can't
modify it to generalize it to allcs and allfamilies.
Use the specified font plus the default. */
- fontsetname = xmalloc (strlen (base_fontname)
- + strlen (xic_default_fontset) + 3);
+ fontsetname = xmalloc_atomic (strlen (base_fontname)
+ + strlen (xic_default_fontset) + 3);
strcpy (fontsetname, base_fontname);
strcat (fontsetname, sep);
strcat (fontsetname, xic_default_fontset);
/* Build the actual font set name. */
len = strlen (base_fontname) + strlen (font_allcs)
+ strlen (font_allfamilies) + strlen (font_all) + 5;
- fontsetname = xmalloc (len);
+ fontsetname = xmalloc_atomic (len);
strcpy (fontsetname, base_fontname);
strcat (fontsetname, sep);
strcat (fontsetname, font_allcs);
This applies even if long is more than 32 bits. The X library
converts to 32 bits before sending to the X server. */
elsize = element_format == 32 ? sizeof (long) : element_format >> 3;
- data = xnmalloc (nelements, elsize);
+ data = xnmalloc_atomic (nelements, elsize);
x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format);
}
char *lang = getenv ("LANG");
ptrdiff_t path_size = 100;
- char *path = xmalloc (path_size);
+ char *path = xmalloc_atomic (path_size);
ptrdiff_t path_len = 0;
const char *p = string;
if (ptr == NULL)
return xstrdup ("/");
- copy = xmalloc (strlen (ptr) + 2);
+ copy = xmalloc_atomic (strlen (ptr) + 2);
strcpy (copy, ptr);
return strcat (copy, "/");
}
char *xdefault;
home = gethomedir ();
- xdefault = xmalloc (strlen (home) + sizeof ".Xdefaults");
+ xdefault = xmalloc_atomic (strlen (home) + sizeof (".Xdefaults"));
strcpy (xdefault, home);
strcat (xdefault, ".Xdefaults");
db = XrmGetFileDatabase (xdefault);
if (total_size_max < bytes_remaining)
goto size_overflow;
total_size = bytes_remaining;
- data = xmalloc (total_size + 1);
+ data = xmalloc_atomic (total_size + 1);
/* Now read, until we've gotten it all. */
while (bytes_remaining)
struct prop_location *wait_object;
if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes)
memory_full (SIZE_MAX);
- *data_ret = xmalloc (min_size_bytes);
+ *data_ret = xmalloc_atomic (min_size_bytes);
*size_bytes_ret = min_size_bytes;
TRACE1 ("Read %u bytes incrementally", min_size_bytes);
props[props_idx]->vals[vp_idx].length = strlen (emacs_program);
props[props_idx]->vals[vp_idx++].value = emacs_program;
- smid_opt = xmalloc (strlen (SMID_OPT) + strlen (client_id) + 1);
+ smid_opt = xmalloc_atomic (strlen (SMID_OPT) + strlen (client_id) + 1);
strcpy (smid_opt, SMID_OPT);
strcat (smid_opt, client_id);
if (cwd)
{
- chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1);
+ chdir_opt = xmalloc_atomic (strlen (CHDIR_OPT) + strlen (cwd) + 1);
strcpy (chdir_opt, CHDIR_OPT);
strcat (chdir_opt, cwd);
/* This malloc will not be freed, but it is only done once, and hopefully
not very large */
- emacs_program = xmalloc (name_len + 1);
+ emacs_program = xmalloc_atomic (name_len + 1);
emacs_program[0] = '\0';
if (! EQ (Vinvocation_directory, Qnil))
if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name))
memory_full (SIZE_MAX);
dpyinfo->x_id = ++x_display_id;
- dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name)
- + SBYTES (Vsystem_name) + 2);
+ dpyinfo->x_id_name = xmalloc_atomic (SBYTES (Vinvocation_name)
+ + SBYTES (Vsystem_name) + 2);
strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"),
SSDATA (Vsystem_name));