+2012-07-05 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * coccinelle/xzalloc.cocci: Semantic patch to convert
+ calls to xmalloc with following memset to xzalloc.
+
2012-07-04 Juanma Barranquero <lekktu@gmail.com>
* CPP-DEFINES (LISP_FLOAT_TYPE): Remove, obsolete.
--- /dev/null
+@@
+expression x;
+expression E;
+@@
+ x =
+- xmalloc
++ xzalloc
+ (E)
+ ...
+- memset (x, 0, E);
+2012-07-05 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Cleanup xmalloc.
+ * lisp.h (xzalloc): New prototype. Omit needless casts.
+ * alloc.c (xzalloc): New function. Omit needless casts.
+ * charset.c: Omit needless casts. Convert all calls to
+ xmalloc with following memset to xzalloc.
+ * dispnew.c: Likewise.
+ * fringe.c: Likewise.
+ * image.c: Likewise.
+ * sound.c: Likewise.
+ * term.c: Likewise.
+ * w32fns.c: Likewise.
+ * w32font.c: Likewise.
+ * w32term.c: Likewise.
+ * xfaces.c: Likewise.
+ * xfns.c: Likewise.
+ * xterm.c: Likewise.
+ * atimer.c: Omit needless casts.
+ * buffer.c: Likewise.
+ * callproc.c: Likewise.
+ * ccl.c: Likewise.
+ * coding.c: Likewise.
+ * composite.c: Likewise.
+ * doc.c: Likewise.
+ * doprnt.c: Likewise.
+ * editfns.c: Likewise.
+ * emacs.c: Likewise.
+ * eval.c: Likewise.
+ * filelock.c: Likewise.
+ * fns.c: Likewise.
+ * gtkutil.c: Likewise.
+ * keyboard.c: Likewise.
+ * lisp.h: Likewise.
+ * lread.c: Likewise.
+ * minibuf.c: Likewise.
+ * msdos.c: Likewise.
+ * print.c: Likewise.
+ * process.c: Likewise.
+ * region-cache.c: Likewise.
+ * search.c: Likewise.
+ * sysdep.c: Likewise.
+ * termcap.c: Likewise.
+ * terminal.c: Likewise.
+ * tparam.c: Likewise.
+ * w16select.c: Likewise.
+ * w32.c: Likewise.
+ * w32reg.c: Likewise.
+ * w32select.c: Likewise.
+ * w32uniscribe.c: Likewise.
+ * widget.c: Likewise.
+ * xdisp.c: Likewise.
+ * xmenu.c: Likewise.
+ * xrdb.c: Likewise.
+ * xselect.c: Likewise.
+
2012-07-05 Paul Eggert <eggert@cs.ucla.edu>
* fileio.c (time_error_value): Check the right error number.
return val;
}
+/* Like the above, but zeroes out the memory just allocated. */
+
+void *
+xzalloc (size_t size)
+{
+ void *val;
+
+ MALLOC_BLOCK_INPUT;
+ val = malloc (size);
+ MALLOC_UNBLOCK_INPUT;
+
+ if (!val && size)
+ memory_full (size);
+ memset (val, 0, size);
+ return val;
+}
/* Like realloc but check for no memory and block interrupt input.. */
xstrdup (const char *s)
{
size_t len = strlen (s) + 1;
- char *p = (char *) xmalloc (len);
+ char *p = xmalloc (len);
memcpy (p, s, len);
return p;
}
if (x == NULL)
abort ();
#else
- x = (struct mem_node *) xmalloc (sizeof *x);
+ x = xmalloc (sizeof *x);
#endif
x->start = start;
x->end = end;
/* Don't allocate a large amount here,
because it might get mmap'd and then its address
might not be usable. */
- purebeg = (char *) xmalloc (10000);
+ purebeg = xmalloc (10000);
pure_size = 10000;
pure_bytes_used_before_overflow += pure_bytes_used - size;
pure_bytes_used = 0;
free_atimers = t->next;
}
else
- t = (struct atimer *) xmalloc (sizeof *t);
+ t = xmalloc (sizeof *t);
/* Fill the atimer structure. */
memset (t, 0, sizeof *t);
len = 10;
/* We can't use alloca here because overlays_at can call xrealloc. */
- overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+ overlay_vec = xmalloc (len * sizeof (Lisp_Object));
/* Put all the overlays we want in a vector in overlay_vec.
Store the length in len. */
CHECK_NUMBER_COERCE_MARKER (end);
len = 10;
- overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+ overlay_vec = xmalloc (len * sizeof (Lisp_Object));
/* Put all the overlays we want in a vector in overlay_vec.
Store the length in len. */
CHECK_NUMBER_COERCE_MARKER (pos);
len = 10;
- overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+ overlay_vec = xmalloc (len * sizeof (Lisp_Object));
/* Put all the overlays we want in a vector in overlay_vec.
Store the length in len.
return pos;
len = 10;
- overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+ overlay_vec = xmalloc (len * sizeof (Lisp_Object));
/* Put all the overlays we want in a vector in overlay_vec.
Store the length in len.
/* MSDOS must have all environment variables malloc'ed, because
low-level libc functions that launch subsidiary processes rely
on that. */
- pwd_var = (char *) xmalloc (i + 6);
+ pwd_var = xmalloc (i + 6);
#else
pwd_var = (char *) alloca (i + 6);
#endif
outbufsize = (ccl.buf_magnification
? str_bytes * ccl.buf_magnification + 256
: str_bytes + 256);
- outp = outbuf = (unsigned char *) xmalloc (outbufsize);
+ outp = outbuf = xmalloc (outbufsize);
consumed_chars = consumed_bytes = 0;
produced_chars = 0;
if (! charset.code_linear_p)
{
- charset.code_space_mask = (unsigned char *) xmalloc (256);
- memset (charset.code_space_mask, 0, 256);
+ charset.code_space_mask = xzalloc (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 = (unsigned char *) xmalloc (dst_bytes);
+ coding->destination = xmalloc (dst_bytes);
coding->dst_bytes = dst_bytes;
coding->dst_multibyte = 0;
}
memory_full (SIZE_MAX);
/* Register the composition in composition_table. */
- cmp = (struct composition *) xmalloc (sizeof (struct composition));
+ cmp = xmalloc (sizeof (struct composition));
cmp->method = method;
cmp->hash_index = hash_index;
static struct glyph_matrix *
new_glyph_matrix (struct glyph_pool *pool)
{
- struct glyph_matrix *result;
-
- /* Allocate and clear. */
- result = (struct glyph_matrix *) xmalloc (sizeof *result);
- memset (result, 0, sizeof *result);
+ struct glyph_matrix *result = xzalloc (sizeof *result);
/* Increment number of allocated matrices. This count is used
to detect memory leaks. */
static struct glyph_pool *
new_glyph_pool (void)
{
- struct glyph_pool *result;
-
- /* Allocate a new glyph_pool and clear it. */
- result = (struct glyph_pool *) xmalloc (sizeof *result);
- memset (result, 0, sizeof *result);
+ struct glyph_pool *result = xzalloc (sizeof *result);
/* For memory leak and double deletion checking. */
++glyph_pool_count;
int i;
struct glyph_matrix *saved;
- saved = (struct glyph_matrix *) xmalloc (sizeof *saved);
- memset (saved, 0, sizeof *saved);
+ saved = xzalloc (sizeof *saved);
saved->nrows = f->current_matrix->nrows;
- saved->rows = (struct glyph_row *) xmalloc (saved->nrows
- * sizeof *saved->rows);
- memset (saved->rows, 0, saved->nrows * sizeof *saved->rows);
+ saved->rows = xzalloc (saved->nrows * sizeof *saved->rows);
for (i = 0; i < saved->nrows; ++i)
{
struct glyph_row *from = f->current_matrix->rows + i;
struct glyph_row *to = saved->rows + i;
ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph);
- to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes);
+ to->glyphs[TEXT_AREA] = xmalloc (nbytes);
memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes);
to->used[TEXT_AREA] = from->used[TEXT_AREA];
}
FRAME_MESSAGE_BUF (f) = new_buffer;
}
else
- FRAME_MESSAGE_BUF (f) = (char *) xmalloc (size);
+ FRAME_MESSAGE_BUF (f) = xmalloc (size);
}
keymap = Voverriding_local_map;
bsize = SBYTES (string);
- bufp = buf = (char *) xmalloc (bsize);
+ bufp = buf = xmalloc (bsize);
strp = SDATA (string);
while (strp < SDATA (string) + SBYTES (string))
{
if (big_buffer)
xfree (big_buffer);
- big_buffer = (char *) xmalloc (size_bound);
+ big_buffer = xmalloc (size_bound);
sprintf_buffer = big_buffer;
size_allocated = size_bound;
}
for (from = environ; *from; from++)
continue;
envptrs = from - environ + 2;
- newenv = to = (char **) xmalloc (envptrs * sizeof (char *)
- + (tzstring ? strlen (tzstring) + 4 : 0));
+ newenv = to = xmalloc (envptrs * sizeof (char *)
+ + (tzstring ? strlen (tzstring) + 4 : 0));
/* Add TZSTRING to the end of environ, as a value for TZ. */
if (tzstring)
/* Copy the data so that it won't move when we GC. */
if (! message_text)
{
- message_text = (char *)xmalloc (80);
+ message_text = xmalloc (80);
message_length = 80;
}
if (SBYTES (val) > message_length)
static void
sort_args (int argc, char **argv)
{
- char **new = (char **) xmalloc (sizeof (char *) * argc);
+ char **new = xmalloc (sizeof (char *) * argc);
/* For each element of argv,
the corresponding element of options is:
0 for an option that takes no arguments,
init_eval_once (void)
{
enum { size = 50 };
- specpdl = (struct specbinding *) xmalloc (size * sizeof (struct specbinding));
+ specpdl = xmalloc (size * sizeof (struct specbinding));
specpdl_size = size;
specpdl_ptr = specpdl;
/* Don't forget to update docs (lispref node "Local Variables"). */
return -1;
}
len = at - lfinfo;
- owner->user = (char *) xmalloc (len + 1);
+ owner->user = xmalloc (len + 1);
memcpy (owner->user, lfinfo, len);
owner->user[len] = 0;
/* The host is everything in between. */
len = dot - at - 1;
- owner->host = (char *) xmalloc (len + 1);
+ owner->host = xmalloc (len + 1);
memcpy (owner->host, at + 1, len);
owner->host[len] = 0;
if (STRING_MULTIBYTE (string))
{
ptrdiff_t bytes = SBYTES (string);
- unsigned char *str = (unsigned char *) xmalloc (bytes);
+ unsigned char *str = xmalloc (bytes);
memcpy (str, SDATA (string), bytes);
bytes = str_as_unibyte (str, bytes);
if (STRING_MULTIBYTE (string))
{
ptrdiff_t chars = SCHARS (string);
- unsigned char *str = (unsigned char *) xmalloc (chars);
+ unsigned char *str = xmalloc (chars);
ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars, 0);
if (converted < chars)
fb.dynamic = 1;
- xfb = (struct fringe_bitmap *) xmalloc (sizeof fb
- + fb.height * BYTES_PER_BITMAP_ROW);
+ xfb = xmalloc (sizeof fb + fb.height * BYTES_PER_BITMAP_ROW);
fb.bits = b = (unsigned short *) (xfb + 1);
memset (b, 0, fb.height);
max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20;
fringe_bitmaps
- = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *));
- fringe_faces
- = (Lisp_Object *) xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object));
+ = xzalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *));
+ fringe_faces = xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object));
for (i = 0; i < max_fringe_bitmaps; i++)
- {
- fringe_bitmaps[i] = NULL;
- fringe_faces[i] = Qnil;
- }
+ fringe_faces[i] = Qnil;
}
#ifdef HAVE_NTGUI
}
else
{
- wv = (widget_value *) xmalloc (sizeof (widget_value));
+ wv = xmalloc (sizeof (widget_value));
malloc_cpt++;
}
memset (wv, 0, sizeof (widget_value));
{
if (! cl_data)
{
- cl_data = (xg_menu_cb_data*) xmalloc (sizeof (*cl_data));
+ cl_data = xmalloc (sizeof (*cl_data));
cl_data->f = f;
cl_data->menu_bar_vector = f->menu_bar_vector;
cl_data->menu_bar_items_used = f->menu_bar_items_used;
id = x_allocate_bitmap_record (f);
dpyinfo->bitmaps[id - 1].img = bitmap;
dpyinfo->bitmaps[id - 1].refcount = 1;
- dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1);
+ dpyinfo->bitmaps[id - 1].file = xmalloc (SBYTES (file) + 1);
dpyinfo->bitmaps[id - 1].depth = 1;
dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap);
dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap);
dpyinfo->bitmaps[id - 1].pixmap = bitmap;
dpyinfo->bitmaps[id - 1].have_mask = 0;
dpyinfo->bitmaps[id - 1].refcount = 1;
- dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1);
+ dpyinfo->bitmaps[id - 1].file = xmalloc (SBYTES (file) + 1);
dpyinfo->bitmaps[id - 1].depth = 1;
dpyinfo->bitmaps[id - 1].height = height;
dpyinfo->bitmaps[id - 1].width = width;
{
/* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
The initialized data segment is read-only. */
- struct image_type *p = (struct image_type *) xmalloc (sizeof *p);
+ struct image_type *p = xmalloc (sizeof *p);
memcpy (p, type, sizeof *p);
p->next = image_types;
image_types = p;
static struct image *
make_image (Lisp_Object spec, EMACS_UINT hash)
{
- struct image *img = (struct image *) xmalloc (sizeof *img);
+ struct image *img = xzalloc (sizeof *img);
Lisp_Object file = image_spec_value (spec, QCfile, NULL);
eassert (valid_image_p (spec));
- memset (img, 0, sizeof *img);
img->dependencies = NILP (file) ? Qnil : list1 (file);
img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
eassert (img->type != NULL);
struct image_cache *
make_image_cache (void)
{
- struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
+ struct image_cache *c = xzalloc (sizeof *c);
int size;
- memset (c, 0, sizeof *c);
size = 50;
- c->images = (struct image **) xmalloc (size * sizeof *c->images);
+ c->images = xmalloc (size * sizeof *c->images);
c->size = size;
size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
- c->buckets = (struct image **) xmalloc (size);
- memset (c->buckets, 0, size);
+ c->buckets = xzalloc (size);
return c;
}
}
/* Allocate image raster. */
- (*ximg)->data = (char *) xmalloc ((*ximg)->bytes_per_line * height);
+ (*ximg)->data = xmalloc ((*ximg)->bytes_per_line * height);
/* Allocate a pixmap of the same size. */
*pixmap = XCreatePixmap (display, window, width, height, depth);
if (stat (file, &st) == 0
&& (fp = fopen (file, "rb")) != NULL
&& 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
- && (buf = (unsigned char *) xmalloc (st.st_size),
+ && (buf = xmalloc (st.st_size),
fread (buf, 1, st.st_size, fp) == st.st_size))
{
*size = st.st_size;
}
bytes_per_line = (*width + 7) / 8 + padding_p;
nbytes = bytes_per_line * *height;
- p = *data = (char *) xmalloc (nbytes);
+ p = *data = xmalloc (nbytes);
if (v10)
{
xpm_init_color_cache (struct frame *f, XpmAttributes *attrs)
{
size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache;
- xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes);
- memset (xpm_color_cache, 0, nbytes);
+ xpm_color_cache = xzalloc (nbytes);
init_color_table ();
if (attrs->valuemask & XpmColorSymbols)
bucket = xpm_color_bucket (color_name);
nbytes = offsetof (struct xpm_cached_color, name) + strlen (color_name) + 1;
- p = (struct xpm_cached_color *) xmalloc (nbytes);
+ p = xmalloc (nbytes);
strcpy (p->name, color_name);
p->color = *color;
p->next = xpm_color_cache[bucket];
init_color_table (void)
{
int size = CT_SIZE * sizeof (*ct_table);
- ct_table = (struct ct_color **) xmalloc (size);
- memset (ct_table, 0, size);
+ ct_table = xzalloc (size);
ct_colors_allocated = 0;
}
if (rc)
{
++ct_colors_allocated;
- p = (struct ct_color *) xmalloc (sizeof *p);
+ p = xmalloc (sizeof *p);
p->r = r;
p->g = g;
p->b = b;
color = RGB_TO_ULONG (r, g, b);
#endif /* HAVE_NTGUI */
++ct_colors_allocated;
- p = (struct ct_color *) xmalloc (sizeof *p);
+ p = xmalloc (sizeof *p);
p->r = r;
p->g = g;
p->b = b;
{
++ct_colors_allocated;
- p = (struct ct_color *) xmalloc (sizeof *p);
+ p = xmalloc (sizeof *p);
p->r = color.red;
p->g = color.green;
p->b = color.blue;
}
else
{
- colors = (unsigned long *) xmalloc (ct_colors_allocated
- * sizeof *colors);
+ colors = xmalloc (ct_colors_allocated * sizeof *colors);
*n = ct_colors_allocated;
for (i = j = 0; i < CT_SIZE; ++i)
if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *colors / img->width < img->height)
memory_full (SIZE_MAX);
- colors = (XColor *) xmalloc (sizeof *colors * img->width * img->height);
+ colors = xmalloc (sizeof *colors * img->width * img->height);
#ifndef HAVE_NTGUI
/* Get the X image IMG->pixmap. */
if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *new / img->width < img->height)
memory_full (SIZE_MAX);
- new = (XColor *) xmalloc (sizeof *new * img->width * img->height);
+ new = xmalloc (sizeof *new * img->width * img->height);
for (y = 0; y < img->height; ++y)
{
#else
/* Create the bit array serving as mask. */
row_width = (img->width + 7) / 8;
- mask_img = xmalloc (row_width * img->height);
- memset (mask_img, 0, row_width * img->height);
+ mask_img = xzalloc (row_width * img->height);
/* Create a memory device context for IMG->pixmap. */
frame_dc = get_frame_dc (f);
if (stat (SDATA (file), &st) == 0
&& (fp = fopen (SDATA (file), "rb")) != NULL
&& 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
- && (buf = (char *) xmalloc (st.st_size),
+ && (buf = xmalloc (st.st_size),
fread (buf, 1, st.st_size, fp) == st.st_size))
{
*size = st.st_size;
if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height
|| min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes)
memory_full (SIZE_MAX);
- pixels = (png_byte *) xmalloc (sizeof *pixels * row_bytes * height);
- rows = (png_byte **) xmalloc (height * sizeof *rows);
+ pixels = xmalloc (sizeof *pixels * row_bytes * height);
+ rows = xmalloc (height * sizeof *rows);
for (i = 0; i < height; ++i)
rows[i] = pixels + i * row_bytes;
return 0;
}
- buf = (uint32 *) xmalloc (sizeof *buf * width * height);
+ buf = xmalloc (sizeof *buf * width * height);
rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0);
void
push_kboard (struct kboard *k)
{
- struct kboard_stack *p
- = (struct kboard_stack *) xmalloc (sizeof (struct kboard_stack));
+ struct kboard_stack *p = xmalloc (sizeof (struct kboard_stack));
p->next = kboard_stack;
p->kboard = current_kboard;
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 = (char *) xmalloc (max_lbl + 1);
+ char *buf = xmalloc (max_lbl + 1);
Lisp_Object new_lbl;
ptrdiff_t caption_len = strlen (capt);
Vdebug_on_event = intern_c_string ("sigusr2");
/* Create the initial keyboard. */
- initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+ initial_kboard = xmalloc (sizeof (KBOARD));
init_kboard (initial_kboard);
/* Vwindow_system is left at t for now. */
initial_kboard->next_kboard = all_kboards;
extern int immediate_quit; /* Nonzero means ^G can quit instantly */
extern void *xmalloc (size_t);
+extern void *xzalloc (size_t);
extern void *xrealloc (void *, size_t);
extern void xfree (void *);
extern void *xnmalloc (ptrdiff_t, ptrdiff_t);
buf = (type) alloca (size); \
else \
{ \
- buf = (type) xmalloc (size); \
+ buf = xmalloc (size); \
sa_must_free = 1; \
record_unwind_protect (safe_alloca_unwind, \
make_save_value (buf, 0)); \
else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \
{ \
Lisp_Object arg_; \
- buf = (Lisp_Object *) xmalloc ((nelt) * sizeof (Lisp_Object)); \
+ buf = xmalloc ((nelt) * sizeof (Lisp_Object)); \
arg_ = make_save_value (buf, nelt); \
XSAVE_VALUE (arg_)->dogc = 1; \
sa_must_free = 1; \
if (saved_doc_string_size == 0)
{
- saved_doc_string = (char *) xmalloc (nskip + extra);
+ saved_doc_string = xmalloc (nskip + extra);
saved_doc_string_size = nskip + extra;
}
if (nskip > saved_doc_string_size)
DEFSYM (Qvariable_documentation, "variable-documentation");
- read_buffer = (char *) xmalloc (size);
+ read_buffer = xmalloc (size);
read_buffer_size = size;
}
\f
val = Qnil;
size = 100;
len = 0;
- line = (char *) xmalloc (size);
+ line = xmalloc (size);
while ((c = getchar ()) != '\n')
{
{
XMenu *menu;
- menu = (XMenu *) xmalloc (sizeof (XMenu));
+ menu = xmalloc (sizeof (XMenu));
menu->allocated = menu->count = menu->panecount = menu->width = 0;
return menu;
}
if (menu->allocated == 0)
{
int count = menu->allocated = 10;
- menu->text = (char **) xmalloc (count * sizeof (char *));
- menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *));
- menu->panenumber = (int *) xmalloc (count * sizeof (int));
- menu->help_text = (const char **) xmalloc (count * sizeof (char *));
+ menu->text = xmalloc (count * sizeof (char *));
+ menu->submenu = xmalloc (count * sizeof (XMenu *));
+ menu->panenumber = xmalloc (count * sizeof (int));
+ menu->help_text = xmalloc (count * sizeof (char *));
}
else if (menu->allocated == menu->count)
{
width = menu->width;
/* We multiply width by 2 to account for possible control characters.
FIXME: cater to non-ASCII characters in menus. */
- text = (struct glyph *) xmalloc ((width * 2 + 2) * sizeof (struct glyph));
+ text = xmalloc ((width * 2 + 2) * sizeof (struct glyph));
ScreenGetCursor (&row, &col);
mouse_get_xy (&mx, &my);
IT_update_begin (sf);
else \
{ \
int new_size = 1000; \
- print_buffer = (char *) xmalloc (new_size); \
+ print_buffer = xmalloc (new_size); \
print_buffer_size = new_size; \
free_print_buffer = 1; \
} \
{
if (datagram_address[s].sa)
abort ();
- datagram_address[s].sa = (struct sockaddr *) xmalloc (lres->ai_addrlen);
+ datagram_address[s].sa = xmalloc (lres->ai_addrlen);
datagram_address[s].len = lres->ai_addrlen;
if (is_server)
{
if (!proc_encode_coding_system[new_outfd])
proc_encode_coding_system[new_outfd]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ = xmalloc (sizeof (struct coding_system));
memcpy (proc_encode_coding_system[new_outfd],
proc_encode_coding_system[old_outfd],
sizeof (struct coding_system));
if (!proc_decode_coding_system[inch])
proc_decode_coding_system[inch]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ = xmalloc (sizeof (struct coding_system));
coding_system = p->decode_coding_system;
if (! NILP (p->filter))
;
if (!proc_encode_coding_system[outch])
proc_encode_coding_system[outch]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ = xmalloc (sizeof (struct coding_system));
setup_coding_system (p->encode_coding_system,
proc_encode_coding_system[outch]);
#endif
struct region_cache *
new_region_cache (void)
{
- struct region_cache *c
- = (struct region_cache *) xmalloc (sizeof (struct region_cache));
+ struct region_cache *c = xmalloc (sizeof (struct region_cache));
c->gap_start = 0;
c->gap_len = NEW_CACHE_GAP;
c->cache_len = 0;
- c->boundaries =
- (struct boundary *) xmalloc ((c->gap_len + c->cache_len)
- * sizeof (*c->boundaries));
+ c->boundaries = xmalloc ((c->gap_len + c->cache_len)
+ * sizeof (*c->boundaries));
c->beg_unchanged = 0;
c->end_unchanged = 0;
the match position. */
if (search_regs.num_regs == 0)
{
- search_regs.start = (regoff_t *) xmalloc (2 * sizeof (regoff_t));
- search_regs.end = (regoff_t *) xmalloc (2 * sizeof (regoff_t));
+ search_regs.start = xmalloc (2 * sizeof (regoff_t));
+ search_regs.end = xmalloc (2 * sizeof (regoff_t));
search_regs.num_regs = 2;
}
substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length
? STRING_BYTES_BOUND
: length * 2 + 100);
- substed = (unsigned char *) xmalloc (substed_alloc_size);
+ substed = xmalloc (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 = (unsigned char *) xmalloc (100);
+ searchbufs[i].buf.buffer = xmalloc (100);
searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
searchbufs[i].regexp = Qnil;
searchbufs[i].whitespace_regexp = Qnil;
#ifndef WINDOWSNT
file = Qnil;
GCPRO2 (sound, file);
- current_sound_device = (struct sound_device *) xmalloc (sizeof (struct sound_device));
- memset (current_sound_device, 0, sizeof (struct sound_device));
- current_sound = (struct sound *) xmalloc (sizeof (struct sound));
- memset (current_sound, 0, sizeof (struct sound));
+ current_sound_device = xzalloc (sizeof (struct sound_device));
+ current_sound = xzalloc (sizeof (struct sound));
record_unwind_protect (sound_cleanup, Qnil);
current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES);
return; /* The tty is suspended. */
if (! tty_out->old_tty)
- tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
+ tty_out->old_tty = xmalloc (sizeof (struct emacs_tty));
emacs_get_tty (fileno (tty_out->input), tty_out->old_tty);
if (! FRAME_TERMCAP_P (f))
abort ();
- t = xmalloc (sizeof (struct tty_output));
- memset (t, 0, sizeof (struct tty_output));
+ t = xzalloc (sizeof (struct tty_output));
t->display_info = FRAME_TERMINAL (f)->display_info.tty;
been_here = 1;
tty = &the_only_display_info;
#else
- tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
+ tty = xzalloc (sizeof (struct tty_display_info));
#endif
- memset (tty, 0, sizeof (struct tty_display_info));
tty->next = tty_list;
tty_list = tty;
terminal->display_info.tty = tty;
tty->terminal = terminal;
- tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
+ tty->Wcm = xmalloc (sizeof (struct cm));
Wcm_clear (tty);
encode_terminal_src_size = 0;
Wcm_clear (tty);
- tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
+ tty->termcap_term_buffer = xmalloc (buffer_size);
/* On some systems, tgetent tries to access the controlling
terminal. */
abort ();
buffer_size = strlen (tty->termcap_term_buffer);
#endif
- tty->termcap_strings_buffer = area = (char *) xmalloc (buffer_size);
+ tty->termcap_strings_buffer = area = xmalloc (buffer_size);
tty->TS_ins_line = tgetstr ("al", address);
tty->TS_ins_multi_lines = tgetstr ("AL", address);
tty->TS_bell = tgetstr ("bl", address);
tty->mouse_highlight.mouse_face_window = Qnil;
#endif
- terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+ terminal->kboard = xmalloc (sizeof (KBOARD));
init_kboard (terminal->kboard);
KVAR (terminal->kboard, Vwindow_system) = Qnil;
terminal->kboard->next_kboard = all_kboards;
p = ptr;
while ((c = *p++) && c != ':' && c != '\n')
;
- ret = (char *) xmalloc (p - ptr + 1);
+ ret = xmalloc (p - ptr + 1);
}
else
ret = *area;
if (!bp)
{
malloc_size = 1 + strlen (term);
- bp = (char *) xmalloc (malloc_size);
+ bp = xmalloc (malloc_size);
}
strcpy (bp, term);
goto ret;
buf.size = BUFSIZE;
/* Add 1 to size to ensure room for terminating null. */
- buf.beg = (char *) xmalloc (buf.size + 1);
+ buf.beg = xmalloc (buf.size + 1);
term = indirect ? indirect : (char *)name;
if (!bp)
{
malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;
- bp = (char *) xmalloc (malloc_size);
+ bp = xmalloc (malloc_size);
}
tc_search_point = bp1 = bp;
terminal->id = next_terminal_id++;
- terminal->keyboard_coding =
- (struct coding_system *) xmalloc (sizeof (struct coding_system));
- terminal->terminal_coding =
- (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ terminal->keyboard_coding = xmalloc (sizeof (struct coding_system));
+ terminal->terminal_coding = xmalloc (sizeof (struct coding_system));
/* If default coding systems for the terminal and the keyboard are
already defined, use them in preference to the defaults. This is
if (outlen == 0)
{
outlen = len + 40;
- new = (char *) xmalloc (outlen);
+ new = xmalloc (outlen);
memcpy (new, outstring, offset);
}
else
setup_coding_system (Fcheck_coding_system (coding_system), &coding);
coding.dst_bytes = nbytes * 4;
- coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
+ coding.destination = xmalloc (coding.dst_bytes);
Vnext_selection_coding_system = Qnil;
coding.mode |= CODING_MODE_LAST_BLOCK;
dst = coding.destination;
goto unblock;
if ((data_size = get_clipboard_data_size (CF_OEMTEXT)) == 0 ||
- (htext = (unsigned char *)xmalloc (data_size)) == 0)
+ (htext = xmalloc (data_size)) == 0)
goto closeclip;
/* need to know final size after '\r' chars are removed because
lpvalue = NULL;
if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS
- && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
+ && (lpvalue = xmalloc (cbData)) != NULL
&& RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS)
{
RegCloseKey (hrootkey);
lpvalue = NULL;
if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS
- && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
+ && (lpvalue = xmalloc (cbData)) != NULL
&& RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS)
{
RegCloseKey (hrootkey);
entry if present. */
if (info == NULL)
{
- info = (volume_info_data *) xmalloc (sizeof (volume_info_data));
+ info = xmalloc (sizeof (volume_info_data));
add_volume_info (root_dir, info);
}
else
}
/* not already mapped, so add to list and recreate Windows palette */
- list = (struct w32_palette_entry *)
- xmalloc (sizeof (struct w32_palette_entry));
+ list = xmalloc (sizeof (struct w32_palette_entry));
SET_W32_COLOR (list->entry, color);
list->refcount = 1;
list->next = FRAME_W32_DISPLAY_INFO (f)->color_list;
if (entry == NULL && alloc)
{
/* not already mapped, so add to list */
- entry = (struct w32_palette_entry *)
- xmalloc (sizeof (struct w32_palette_entry));
+ entry = xmalloc (sizeof (struct w32_palette_entry));
SET_W32_COLOR (entry->entry, XUINT (tem));
entry->next = NULL;
*prev = entry;
{
char *str = SSDATA (Vx_resource_name);
- f->namebuf = (char *) xmalloc (strlen (str) + 1);
+ f->namebuf = xmalloc (strlen (str) + 1);
strcpy (f->namebuf, str);
}
f->terminal = dpyinfo->terminal;
f->output_method = output_w32;
- f->output_data.w32 =
- (struct w32_output *) xmalloc (sizeof (struct w32_output));
- memset (f->output_data.w32, 0, sizeof (struct w32_output));
+ f->output_data.w32 = xzalloc (sizeof (struct w32_output));
FRAME_FONTSET (f) = -1;
f->icon_name
counts etc. */
f->terminal = dpyinfo->terminal;
f->output_method = output_w32;
- f->output_data.w32 =
- (struct w32_output *) xmalloc (sizeof (struct w32_output));
- memset (f->output_data.w32, 0, sizeof (struct w32_output));
+ f->output_data.w32 = xzalloc (sizeof (struct w32_output));
FRAME_FONTSET (f) = -1;
f->icon_name = Qnil;
return Qnil;
}
/* Allocate memory for the PRINTER_INFO_2 struct */
- ppi2 = (PRINTER_INFO_2 *) xmalloc (dwNeeded);
+ ppi2 = xmalloc (dwNeeded);
if (!ppi2)
{
ClosePrinter (hPrn);
if (!w32_font->cached_metrics[block])
{
w32_font->cached_metrics[block]
- = xmalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
- memset (w32_font->cached_metrics[block], 0,
- CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
+ = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
}
char_metric = w32_font->cached_metrics[block] + pos_in_block;
}
ok = (keyname
- && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
+ && (lpvalue = xmalloc (cbData)) != NULL
&& RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS);
RegCloseKey (hrootkey);
setup_windows_coding_system (coding_system, &coding);
coding.dst_bytes = SBYTES (current_text) * 2;
- coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
+ coding.destination = xmalloc (coding.dst_bytes);
encode_coding_object (&coding, current_text, 0, 0,
SCHARS (current_text), SBYTES (current_text), Qnil);
XGCValues *
XCreateGC (void *ignore, Window window, unsigned long mask, XGCValues *xgcv)
{
- XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues));
- memset (gc, 0, sizeof (XGCValues));
+ XGCValues *gc = xzalloc (sizeof (XGCValues));
XChangeGC (ignore, gc, mask, xgcv);
w32_display_name_list);
dpyinfo->name_list_element = XCAR (w32_display_name_list);
- dpyinfo->w32_id_name
- = (char *) xmalloc (SCHARS (Vinvocation_name)
- + SCHARS (Vsystem_name)
- + 2);
+ dpyinfo->w32_id_name = xmalloc (SCHARS (Vinvocation_name)
+ + SCHARS (Vsystem_name) + 2);
sprintf (dpyinfo->w32_id_name, "%s@%s",
SDATA (Vinvocation_name), SDATA (Vsystem_name));
/* We don't yet support separate terminals on W32, so don't try to share
keyboards between virtual terminals that are on the same physical
terminal like X does. */
- terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+ terminal->kboard = xmalloc (sizeof (KBOARD));
init_kboard (terminal->kboard);
KVAR (terminal->kboard, Vwindow_system) = intern ("w32");
terminal->kboard->next_kboard = all_kboards;
terminal = w32_create_terminal (dpyinfo);
/* Set the name of the terminal. */
- terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
+ terminal->name = xmalloc (SBYTES (display_name) + 1);
strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
terminal->name[SBYTES (display_name)] = 0;
/* First we need to break up the glyph string into runs of glyphs that
can be treated together. First try a single run. */
max_items = 2;
- items = (SCRIPT_ITEM *) xmalloc (sizeof (SCRIPT_ITEM) * max_items + 1);
+ items = xmalloc (sizeof (SCRIPT_ITEM) * max_items + 1);
while ((result = ScriptItemize (chars, nchars, max_items, NULL, NULL,
items, &nitems)) == E_OUTOFMEMORY)
flags & XNegative ? '-' : '+', x < 0 ? -x : x,
flags & YNegative ? '-' : '+', y < 0 ? -y : y);
len = strlen (shell_position) + 1;
- tem = (char *) xmalloc (len);
+ tem = xmalloc (len);
strncpy (tem, shell_position, len);
XtVaSetValues (wmshell, XtNgeometry, tem, NULL);
}
char *tem;
sprintf (shell_position, "=%dx%d", pixel_width, pixel_height);
len = strlen (shell_position) + 1;
- tem = (char *) xmalloc (len);
+ tem = xmalloc (len);
strncpy (tem, shell_position, len);
XtVaSetValues (wmshell, XtNgeometry, tem, NULL);
}
/* Allocate the buffer for frame titles.
Also used for `format-mode-line'. */
int size = 100;
- mode_line_noprop_buf = (char *) xmalloc (size);
+ mode_line_noprop_buf = xmalloc (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;
static struct face *
make_realized_face (Lisp_Object *attr)
{
- struct face *face = (struct face *) xmalloc (sizeof *face);
- memset (face, 0, sizeof *face);
+ struct face *face = xzalloc (sizeof *face);
face->ascii_face = face;
memcpy (face->lface, attr, sizeof face->lface);
return face;
struct face_cache *c;
int size;
- c = (struct face_cache *) xmalloc (sizeof *c);
- memset (c, 0, sizeof *c);
+ c = xzalloc (sizeof *c);
size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
- c->buckets = (struct face **) xmalloc (size);
- memset (c->buckets, 0, size);
+ c->buckets = xzalloc (size);
c->size = 50;
- c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id);
+ c->faces_by_id = xmalloc (c->size * sizeof *c->faces_by_id);
c->f = f;
c->menu_face_changed_p = menu_face_changed_default;
return c;
struct face_cache *cache = FRAME_FACE_CACHE (f);
struct face *face;
- face = (struct face *) xmalloc (sizeof *face);
+ face = xmalloc (sizeof *face);
*face = *base_face;
face->gc = 0;
face->extra = NULL;
{
char *str = SSDATA (Vx_resource_name);
- f->namebuf = (char *) xmalloc (strlen (str) + 1);
+ f->namebuf = xmalloc (strlen (str) + 1);
strcpy (f->namebuf, str);
}
f->terminal = dpyinfo->terminal;
f->output_method = output_x_window;
- f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
- memset (f->output_data.x, 0, sizeof (struct x_output));
+ f->output_data.x = xzalloc (sizeof (struct x_output));
f->output_data.x->icon_bitmap = -1;
FRAME_FONTSET (f) = -1;
f->output_data.x->scroll_bar_foreground_pixel = -1;
from this point on, x_destroy_window might screw up reference
counts etc. */
f->output_method = output_x_window;
- f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
- memset (f->output_data.x, 0, sizeof (struct x_output));
+ f->output_data.x = xzalloc (sizeof (struct x_output));
f->output_data.x->icon_bitmap = -1;
FRAME_FONTSET (f) = -1;
f->output_data.x->scroll_bar_foreground_pixel = -1;
else if (!f->output_data.x->saved_menu_event && !deep_p)
{
deep_p = 1;
- f->output_data.x->saved_menu_event = (XEvent*)xmalloc (sizeof (XEvent));
+ f->output_data.x->saved_menu_event = xmalloc (sizeof (XEvent));
f->output_data.x->saved_menu_event->type = 0;
}
if (result)
{
- char *copy = (char *) xmalloc (strlen (result) + 1);
+ char *copy = xmalloc (strlen (result) + 1);
strcpy (copy, result);
return copy;
}
char *lang = getenv ("LANG");
ptrdiff_t path_size = 100;
- char *path = (char *) xmalloc (path_size);
+ char *path = xmalloc (path_size);
ptrdiff_t path_len = 0;
const char *p = string;
if (ptr == NULL)
return xstrdup ("/");
- copy = (char *) xmalloc (strlen (ptr) + 2);
+ copy = xmalloc (strlen (ptr) + 2);
strcpy (copy, ptr);
strcat (copy, "/");
char *xdefault;
home = gethomedir ();
- xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults"));
+ xdefault = xmalloc (strlen (home) + sizeof (".Xdefaults"));
strcpy (xdefault, home);
strcat (xdefault, ".Xdefaults");
db = XrmGetFileDatabase (xdefault);
}
}
- queue_tmp
- = (struct selection_event_queue *) xmalloc (sizeof (struct selection_event_queue));
-
- if (queue_tmp != NULL)
- {
- TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp);
- queue_tmp->event = *event;
- queue_tmp->next = selection_queue;
- selection_queue = queue_tmp;
- }
+ queue_tmp = xmalloc (sizeof (struct selection_event_queue));
+ TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp);
+ queue_tmp->event = *event;
+ queue_tmp->next = selection_queue;
+ selection_queue = queue_tmp;
}
/* Start queuing SELECTION_REQUEST_EVENT events. */
expect_property_change (Display *display, Window window,
Atom property, int state)
{
- struct prop_location *pl = (struct prop_location *) xmalloc (sizeof *pl);
+ struct prop_location *pl = xmalloc (sizeof *pl);
pl->identifier = ++prop_location_identifier;
pl->display = display;
pl->window = window;
struct prop_location *wait_object;
if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes)
memory_full (SIZE_MAX);
- *data_ret = (unsigned char *) xmalloc (min_size_bytes);
+ *data_ret = xmalloc (min_size_bytes);
*size_bytes_ret = min_size_bytes;
TRACE1 ("Read %u bytes incrementally", min_size_bytes);
}
else if (SYMBOLP (obj))
{
- *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1);
+ *data_ret = xmalloc (sizeof (Atom) + 1);
*format_ret = 32;
*size_ret = 1;
(*data_ret) [sizeof (Atom)] = 0;
}
else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX))
{
- *data_ret = (unsigned char *) xmalloc (sizeof (short) + 1);
+ *data_ret = xmalloc (sizeof (short) + 1);
*format_ret = 16;
*size_ret = 1;
(*data_ret) [sizeof (short)] = 0;
|| (CONSP (XCDR (obj))
&& INTEGERP (XCAR (XCDR (obj)))))))
{
- *data_ret = (unsigned char *) xmalloc (sizeof (unsigned long) + 1);
+ *data_ret = xmalloc (sizeof (unsigned long) + 1);
*format_ret = 32;
*size_ret = 1;
(*data_ret) [sizeof (unsigned long)] = 0;
do \
{ \
if (f->output_data.x->saved_menu_event == 0) \
- f->output_data.x->saved_menu_event \
- = (XEvent *) xmalloc (sizeof (XEvent)); \
- *f->output_data.x->saved_menu_event = event; \
+ f->output_data.x->saved_menu_event = \
+ xmalloc (sizeof (XEvent)); \
+ *f->output_data.x->saved_menu_event = event; \
inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \
XSETFRAME (inev.ie.frame_or_window, f); \
} \
struct xim_inst_t *xim_inst;
ptrdiff_t len;
- xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
+ xim_inst = xmalloc (sizeof (struct xim_inst_t));
dpyinfo->xim_callback_data = xim_inst;
xim_inst->dpyinfo = dpyinfo;
len = strlen (resource_name);
- xim_inst->resource_name = (char *) xmalloc (len + 1);
+ xim_inst->resource_name = xmalloc (len + 1);
memcpy (xim_inst->resource_name, resource_name, len + 1);
XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
resource_name, emacs_class,
/* We have definitely succeeded. Record the new connection. */
- dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
- memset (dpyinfo, 0, sizeof *dpyinfo);
+ dpyinfo = xzalloc (sizeof (struct x_display_info));
hlinfo = &dpyinfo->mouse_highlight;
terminal = x_create_terminal (dpyinfo);
terminal->kboard = share->terminal->kboard;
else
{
- terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+ terminal->kboard = xmalloc (sizeof (KBOARD));
init_kboard (terminal->kboard);
KVAR (terminal->kboard, Vwindow_system) = Qx;
dpyinfo->display = dpy;
/* Set the name of the terminal. */
- terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
+ terminal->name = xmalloc (SBYTES (display_name) + 1);
memcpy (terminal->name, SSDATA (display_name), SBYTES (display_name));
terminal->name[SBYTES (display_name)] = 0;
lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@";
if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name))
memory_full (SIZE_MAX);
- dpyinfo->x_id_name
- = (char *) xmalloc (SBYTES (Vinvocation_name)
- + SBYTES (Vsystem_name)
- + 2);
+ dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name)
+ + SBYTES (Vsystem_name) + 2);
strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"),
SSDATA (Vsystem_name));