2012-08-03 Paul Eggert <eggert@cs.ucla.edu>
+ Remove unnecessary casts involving pointers.
+ These casts are no longer needed now that we assume C89 or later,
+ since they involve casting to or from void *.
+ * alloc.c (make_pure_string, make_pure_c_string, pure_cons)
+ (make_pure_float, make_pure_vector):
+ * lisp.h (SAFE_ALLOCA, SAFE_ALLOCA_LISP):
+ * macros.c (Fstart_kbd_macro):
+ * menu.c (find_and_return_menu_selection):
+ * minibuf.c (read_minibuf_noninteractive):
+ * sysdep.c (closedir):
+ * xdisp.c (x_produce_glyphs):
+ * xfaces.c (compare_fonts_by_sort_order):
+ * xfns.c (x_real_positions, select_visual):
+ * xselect.c (x_stop_queuing_selection_requests)
+ (x_get_window_property, x_get_window_property_as_lisp_data):
+ * xterm.c (x_set_frame_alpha, x_find_modifier_meanings):
+ Remove unnecessary pointer casts.
+ * alloc.c (record_xmalloc): New function.
+ * lisp.h (record_xmalloc): New decl.
+ (SAFE_ALLOCA): Now takes just one arg -- the size -- and acts
+ more like a function. This is because the pointer cast is not
+ needed. All uses changed.
+ * print.c (print_string, print_error_message): Avoid length recalc.
+
Improve fix for macroexp crash with debugging (Bug#12118).
* lisp.h (ASET) [ENABLE_CHECKING]: Pay attention to
ARRAY_MARK_FLAG when checking subscripts, because ASET is
return Qnil;
}
+/* 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 (safe_alloca_unwind, make_save_value (p, 0));
+ return p;
+}
+
/* Like malloc but used for allocating Lisp data. NBYTES is the
number of bytes to allocate, TYPE describes the intended use of the
ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte)
{
Lisp_Object string;
- struct Lisp_String *s;
-
- s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
+ struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
s->data = (unsigned char *) find_string_data_in_pure (data, nbytes);
if (s->data == NULL)
{
- s->data = (unsigned char *) pure_alloc (nbytes + 1, -1);
+ s->data = pure_alloc (nbytes + 1, -1);
memcpy (s->data, data, nbytes);
s->data[nbytes] = '\0';
}
make_pure_c_string (const char *data, ptrdiff_t nchars)
{
Lisp_Object string;
- struct Lisp_String *s;
-
- s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
+ struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
s->size = nchars;
s->size_byte = -1;
s->data = (unsigned char *) data;
Lisp_Object
pure_cons (Lisp_Object car, Lisp_Object cdr)
{
- register Lisp_Object new;
- struct Lisp_Cons *p;
-
- p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons);
+ Lisp_Object new;
+ struct Lisp_Cons *p = pure_alloc (sizeof *p, Lisp_Cons);
XSETCONS (new, p);
XSETCAR (new, Fpurecopy (car));
XSETCDR (new, Fpurecopy (cdr));
static Lisp_Object
make_pure_float (double num)
{
- register Lisp_Object new;
- struct Lisp_Float *p;
-
- p = (struct Lisp_Float *) pure_alloc (sizeof *p, Lisp_Float);
+ Lisp_Object new;
+ struct Lisp_Float *p = pure_alloc (sizeof *p, Lisp_Float);
XSETFLOAT (new, p);
XFLOAT_INIT (new, num);
return new;
make_pure_vector (ptrdiff_t len)
{
Lisp_Object new;
- struct Lisp_Vector *p;
size_t size = header_size + len * word_size;
-
- p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike);
+ struct Lisp_Vector *p = pure_alloc (size, Lisp_Vectorlike);
XSETVECTOR (new, p);
XVECTOR (new)->header.size = len;
return new;
&& SREF (path, 1) == ':')
path = Fsubstring (path, make_number (2), Qnil);
- SAFE_ALLOCA (new_argv, const unsigned char **,
- (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv);
+ new_argv = SAFE_ALLOCA ((nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv);
if (nargs > 4)
{
ptrdiff_t i;
Lisp_Object coding_systems;
Lisp_Object val, *args2;
ptrdiff_t i;
- char *tempfile;
- Lisp_Object tmpdir, pattern;
+ Lisp_Object tmpdir;
if (STRINGP (Vtemporary_file_directory))
tmpdir = Vtemporary_file_directory;
{
USE_SAFE_ALLOCA;
- pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir);
- SAFE_ALLOCA (tempfile, char *, SBYTES (pattern) + 1);
+ Lisp_Object pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir);
+ char *tempfile = SAFE_ALLOCA (SBYTES (pattern) + 1);
memcpy (tempfile, SDATA (pattern), SBYTES (pattern) + 1);
coding_systems = Qt;
ptrdiff_t i, i_byte, size = SCHARS (obj);
int len;
USE_SAFE_ALLOCA;
- unsigned char *dst, *o;
ptrdiff_t o_size = (size < STRING_BYTES_BOUND / MAX_MULTIBYTE_LENGTH
? size * MAX_MULTIBYTE_LENGTH
: STRING_BYTES_BOUND);
- SAFE_ALLOCA (dst, void *, o_size);
- o = dst;
+ unsigned char *dst = SAFE_ALLOCA (o_size);
+ unsigned char *o = dst;
for (i = i_byte = 0; i < size; i++, i_byte += len)
{
(ptrdiff_t n, Lisp_Object *args)
{
ptrdiff_t i;
- unsigned char *buf, *p;
Lisp_Object str;
USE_SAFE_ALLOCA;
-
- SAFE_ALLOCA (buf, unsigned char *, n);
- p = buf;
+ unsigned char *buf = SAFE_ALLOCA (n);
+ unsigned char *p = buf;
for (i = 0; i < n; i++)
{
/* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
large (larger than MAX_ALLOCA). */
- SAFE_ALLOCA (head, struct charset_map_entries *,
- sizeof (struct charset_map_entries));
+ head = SAFE_ALLOCA (sizeof *head);
entries = head;
memset (entries, 0, sizeof (struct charset_map_entries));
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- SAFE_ALLOCA (entries->next, struct charset_map_entries *,
- sizeof (struct charset_map_entries));
+ entries->next = SAFE_ALLOCA (sizeof *entries->next);
entries = entries->next;
memset (entries, 0, sizeof (struct charset_map_entries));
n_entries = 0;
/* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
large (larger than MAX_ALLOCA). */
- SAFE_ALLOCA (head, struct charset_map_entries *,
- sizeof (struct charset_map_entries));
+ head = SAFE_ALLOCA (sizeof *head);
entries = head;
memset (entries, 0, sizeof (struct charset_map_entries));
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- SAFE_ALLOCA (entries->next, struct charset_map_entries *,
- sizeof (struct charset_map_entries));
+ entries->next = SAFE_ALLOCA (sizeof *entries->next);
entries = entries->next;
memset (entries, 0, sizeof (struct charset_map_entries));
}
{
/* We must relocate the string data. */
ptrdiff_t nchars = SCHARS (array);
- unsigned char *str;
USE_SAFE_ALLOCA;
+ unsigned char *str = SAFE_ALLOCA (nbytes);
- SAFE_ALLOCA (str, unsigned char *, nbytes);
memcpy (str, SDATA (array), nbytes);
allocate_string_data (XSTRING (array), nchars,
nbytes + new_bytes - prev_bytes);
ptrdiff_t len = NAMLEN (dp);
ptrdiff_t pos = SCHARS (dirname);
int value;
- char *fullname;
USE_SAFE_ALLOCA;
- SAFE_ALLOCA (fullname, char *, len + pos + 2);
+ char *fullname = SAFE_ALLOCA (len + pos + 2);
#ifdef MSDOS
/* Some fields of struct stat are *very* expensive to compute on MS-DOS,
/* sizeof ("../etc/") == 8 */
if (minsize < 8)
minsize = 8;
- SAFE_ALLOCA (name, char *, minsize + SCHARS (file) + 8);
+ name = SAFE_ALLOCA (minsize + SCHARS (file) + 8);
strcpy (name, SSDATA (docdir));
strcat (name, SSDATA (file));
}
if (format_end == 0)
format_end = format + strlen (format);
- if (format_end - format < sizeof (fixed_buffer) - 1)
- fmtcpy = fixed_buffer;
- else
- SAFE_ALLOCA (fmtcpy, char *, format_end - format + 1);
+ fmtcpy = (format_end - format < sizeof (fixed_buffer) - 1
+ ? fixed_buffer
+ : SAFE_ALLOCA (format_end - format + 1));
bufsize--;
if (STRING_BYTES_BOUND <= len)
string_overflow ();
size = len + 1;
- SAFE_ALLOCA (buf, char *, size);
+ buf = SAFE_ALLOCA (size);
}
UNBLOCK_INPUT;
int m = offset / 60;
int am = offset < 0 ? - m : m;
char buf[sizeof "+00" + INT_STRLEN_BOUND (int)];
- zone_name = make_formatted_string (buf, "%c%02d%02d",
+ zone_name = make_formatted_string (buf, "%c%02d%02d",
(offset < 0 ? '-' : '+'),
am / 60, am % 60);
}
ptrdiff_t i;
if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs)
memory_full (SIZE_MAX);
- SAFE_ALLOCA (info, struct info *, (nargs + 1) * sizeof *info + formatlen);
+ info = SAFE_ALLOCA ((nargs + 1) * sizeof *info + formatlen);
discarded = (char *) &info[nargs + 1];
for (i = 0; i < nargs + 1; i++)
{
{
USE_SAFE_ALLOCA;
- SAFE_ALLOCA (temp, unsigned char *, len2_byte);
+ temp = SAFE_ALLOCA (len2_byte);
/* Don't precompute these addresses. We have to compute them
at the last minute, because the relocating allocator might
{
USE_SAFE_ALLOCA;
- SAFE_ALLOCA (temp, unsigned char *, len1_byte);
+ temp = SAFE_ALLOCA (len1_byte);
start1_addr = BYTE_POS_ADDR (start1_byte);
start2_addr = BYTE_POS_ADDR (start2_byte);
memcpy (temp, start1_addr, len1_byte);
if (!NULL_INTERVAL_P (tmp_interval3))
set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3);
- SAFE_ALLOCA (temp, unsigned char *, len1_byte);
+ temp = SAFE_ALLOCA (len1_byte);
start1_addr = BYTE_POS_ADDR (start1_byte);
start2_addr = BYTE_POS_ADDR (start2_byte);
memcpy (temp, start1_addr, len1_byte);
set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
/* holds region 2 */
- SAFE_ALLOCA (temp, unsigned char *, len2_byte);
+ temp = SAFE_ALLOCA (len2_byte);
start1_addr = BYTE_POS_ADDR (start1_byte);
start2_addr = BYTE_POS_ADDR (start2_byte);
memcpy (temp, start2_addr, len2_byte);
set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
/* holds region 1 */
- SAFE_ALLOCA (temp, unsigned char *, len1_byte);
+ temp = SAFE_ALLOCA (len1_byte);
start1_addr = BYTE_POS_ADDR (start1_byte);
start2_addr = BYTE_POS_ADDR (start2_byte);
memcpy (temp, start1_addr, len1_byte);
msg = Fformat (3, args);
GCPRO1 (msg);
nbytes = SBYTES (msg);
- SAFE_ALLOCA (msgbuf, char *, nbytes);
+ msgbuf = SAFE_ALLOCA (nbytes);
memcpy (msgbuf, SDATA (msg), nbytes);
for (i = 0; i < 3; ++i)
static int
lock_file_1 (char *lfname, int force)
{
- register int err;
- printmax_t boot, pid;
- const char *user_name;
- const char *host_name;
- char *lock_info_str;
- ptrdiff_t lock_info_size;
+ int err;
int symlink_errno;
USE_SAFE_ALLOCA;
/* Call this first because it can GC. */
- boot = get_boot_time ();
-
- if (STRINGP (Fuser_login_name (Qnil)))
- user_name = SSDATA (Fuser_login_name (Qnil));
- else
- user_name = "";
- if (STRINGP (Fsystem_name ()))
- host_name = SSDATA (Fsystem_name ());
- else
- host_name = "";
- lock_info_size = (strlen (user_name) + strlen (host_name)
- + 2 * INT_STRLEN_BOUND (printmax_t)
- + sizeof "@.:");
- SAFE_ALLOCA (lock_info_str, char *, lock_info_size);
- pid = getpid ();
+ printmax_t boot = get_boot_time ();
+
+ Lisp_Object luser_name = Fuser_login_name (Qnil);
+ char const *user_name = STRINGP (luser_name) ? SSDATA (luser_name) : "";
+ Lisp_Object lhost_name = Fsystem_name ();
+ char const *host_name = STRINGP (lhost_name) ? SSDATA (lhost_name) : "";
+ ptrdiff_t lock_info_size = (strlen (user_name) + strlen (host_name)
+ + 2 * INT_STRLEN_BOUND (printmax_t)
+ + sizeof "@.:");
+ char *lock_info_str = SAFE_ALLOCA (lock_info_size);
+ printmax_t pid = getpid ();
esprintf (lock_info_str, boot ? "%s@%s.%"pMd":%"pMd : "%s@%s.%"pMd,
user_name, host_name, pid, boot);
locker_size = (strlen (lock_info.user) + strlen (lock_info.host)
+ INT_STRLEN_BOUND (printmax_t)
+ sizeof "@ (pid )");
- SAFE_ALLOCA (locker, char *, locker_size);
+ locker = SAFE_ALLOCA (locker_size);
pid = lock_info.pid;
esprintf (locker, "%s@%s (pid %"pMd")",
lock_info.user, lock_info.host, pid);
if (nbytes == SBYTES (string))
return string;
- SAFE_ALLOCA (buf, unsigned char *, nbytes);
+ buf = SAFE_ALLOCA (nbytes);
copy_text (SDATA (string), buf, SBYTES (string),
0, 1);
if (nbytes == SBYTES (string))
return make_multibyte_string (SSDATA (string), nbytes, nbytes);
- SAFE_ALLOCA (buf, unsigned char *, nbytes);
+ buf = SAFE_ALLOCA (nbytes);
memcpy (buf, SDATA (string), SBYTES (string));
str_to_multibyte (buf, nbytes, SBYTES (string));
nchars = SCHARS (string);
- SAFE_ALLOCA (buf, unsigned char *, nchars);
+ buf = SAFE_ALLOCA (nchars);
copy_text (SDATA (string), buf, SBYTES (string),
1, 0);
allength = length + length/3 + 1;
allength += allength / MIME_LINE_LENGTH + 1 + 6;
- SAFE_ALLOCA (encoded, char *, allength);
+ encoded = SAFE_ALLOCA (allength);
encoded_length = base64_encode_1 ((char *) BYTE_POS_ADDR (ibeg),
encoded, length, NILP (no_line_break),
!NILP (BVAR (current_buffer, enable_multibyte_characters)));
allength += allength / MIME_LINE_LENGTH + 1 + 6;
/* We need to allocate enough room for decoding the text. */
- SAFE_ALLOCA (encoded, char *, allength);
+ encoded = SAFE_ALLOCA (allength);
encoded_length = base64_encode_1 (SSDATA (string),
encoded, length, NILP (no_line_break),
working on a multibyte buffer, each decoded code may occupy at
most two bytes. */
allength = multibyte ? length * 2 : length;
- SAFE_ALLOCA (decoded, char *, allength);
+ decoded = SAFE_ALLOCA (allength);
move_gap_both (XFASTINT (beg), ibeg);
decoded_length = base64_decode_1 ((char *) BYTE_POS_ADDR (ibeg),
length = SBYTES (string);
/* We need to allocate enough room for decoding the text. */
- SAFE_ALLOCA (decoded, char *, length);
+ decoded = SAFE_ALLOCA (length);
/* The decoded result should be unibyte. */
decoded_length = base64_decode_1 (SSDATA (string), decoded, length,
maxlen = ASIZE (vec);
}
- SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * maxlen);
+ data = SAFE_ALLOCA (maxlen * sizeof *data);
best_score = 0xFFFFFFFF;
best_entity = Qnil;
char *
x_get_resource_string (const char *attribute, const char *class)
{
- char *name_key;
- char *class_key;
char *result;
struct frame *sf = SELECTED_FRAME ();
ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name);
/* Allocate space for the components, the dots which separate them,
and the final '\0'. */
- SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2);
- class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2);
+ char *name_key = SAFE_ALLOCA (invocation_namelen + strlen (attribute) + 2);
+ char *class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2);
esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
sprintf (class_key, "%s.%s", EMACS_CLASS, class);
ptrdiff_t len = (SBYTES (name_alist_or_stem)
+ sizeof "-" + INT_STRLEN_BOUND (EMACS_INT));
USE_SAFE_ALLOCA;
- SAFE_ALLOCA (buf, char *, len);
+ buf = SAFE_ALLOCA (len);
esprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem),
XINT (symbol_int) + 1);
value = intern (buf);
if (!NILP (Voverriding_local_map_menu_flag))
{
/* Yes, use them (if non-nil) as well as the global map. */
- maps = (Lisp_Object *) alloca (3 * sizeof (maps[0]));
+ maps = alloca (3 * sizeof (maps[0]));
nmaps = 0;
if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
{
if (NILP (no_angles))
{
- char *buffer;
Lisp_Object result;
USE_SAFE_ALLOCA;
- SAFE_ALLOCA (buffer, char *,
- sizeof "<>" + SBYTES (SYMBOL_NAME (key)));
+ char *buffer = SAFE_ALLOCA (sizeof "<>"
+ + SBYTES (SYMBOL_NAME (key)));
esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key)));
result = build_string (buffer);
SAFE_FREE ();
enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 };
extern Lisp_Object safe_alloca_unwind (Lisp_Object);
+extern void *record_xmalloc (size_t);
#define USE_SAFE_ALLOCA \
ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0
/* SAFE_ALLOCA allocates a simple buffer. */
-#define SAFE_ALLOCA(buf, type, size) \
- do { \
- if ((size) < MAX_ALLOCA) \
- buf = (type) alloca (size); \
- else \
- { \
- buf = xmalloc (size); \
- sa_must_free = 1; \
- record_unwind_protect (safe_alloca_unwind, \
- make_save_value (buf, 0)); \
- } \
- } while (0)
+#define SAFE_ALLOCA(size) ((size) < MAX_ALLOCA \
+ ? alloca (size) \
+ : (sa_must_free = 1, record_xmalloc (size)))
/* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER *
NITEMS items, each of the same type as *BUF. MULTIPLIER must
#define SAFE_ALLOCA_LISP(buf, nelt) \
do { \
if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \
- buf = (Lisp_Object *) alloca ((nelt) * sizeof (Lisp_Object)); \
+ buf = alloca ((nelt) * sizeof (Lisp_Object)); \
else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \
{ \
Lisp_Object arg_; \
/* Don't log the warning before we've initialized!! */
if (initialized)
{
- char *buffer;
- ptrdiff_t message_len;
USE_SAFE_ALLOCA;
- SAFE_ALLOCA (buffer, char *,
- SBYTES (dirname) + strlen (format) - (sizeof "%s" - 1) + 1);
- message_len = esprintf (buffer, format, SDATA (dirname));
+ char *buffer = SAFE_ALLOCA (SBYTES (dirname)
+ + strlen (format) - (sizeof "%s" - 1) + 1);
+ ptrdiff_t message_len = esprintf (buffer, format, SDATA (dirname));
message_dolog (buffer, message_len, 0, STRING_MULTIBYTE (dirname));
SAFE_FREE ();
}
if (current_kboard->kbd_macro_bufsize > 200)
{
current_kboard->kbd_macro_buffer
- = (Lisp_Object *)xrealloc (current_kboard->kbd_macro_buffer,
- 30 * sizeof (Lisp_Object));
+ = xrealloc (current_kboard->kbd_macro_buffer,
+ 30 * sizeof (Lisp_Object));
current_kboard->kbd_macro_bufsize = 30;
}
current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer;
prefix = entry = Qnil;
i = 0;
- subprefix_stack =
- (Lisp_Object *)alloca (menu_items_used * sizeof (Lisp_Object));
+ subprefix_stack = alloca (menu_items_used * sizeof (Lisp_Object));
while (i < menu_items_used)
{
if (STRING_BYTES_BOUND / 2 < size)
memory_full (SIZE_MAX);
size *= 2;
- line = (char *) xrealloc (line, size);
+ line = xrealloc (line, size);
}
line[len++] = c;
}
{
/* Output to echo area. */
ptrdiff_t nbytes = SBYTES (string);
- char *buffer;
/* Copy the string contents so that relocation of STRING by
GC does not cause trouble. */
USE_SAFE_ALLOCA;
-
- SAFE_ALLOCA (buffer, char *, nbytes);
+ char *buffer = SAFE_ALLOCA (nbytes);
memcpy (buffer, SDATA (string), nbytes);
- strout (buffer, chars, SBYTES (string), printcharfun);
+ strout (buffer, chars, nbytes, printcharfun);
SAFE_FREE ();
}
if (!NILP (caller) && SYMBOLP (caller))
{
Lisp_Object cname = SYMBOL_NAME (caller);
- char *name;
+ ptrdiff_t cnamelen = SBYTES (cname);
USE_SAFE_ALLOCA;
- SAFE_ALLOCA (name, char *, SBYTES (cname));
- memcpy (name, SDATA (cname), SBYTES (cname));
- message_dolog (name, SBYTES (cname), 0, 0);
+ char *name = SAFE_ALLOCA (cnamelen);
+ memcpy (name, SDATA (cname), cnamelen);
+ message_dolog (name, cnamelen, 0, 0);
message_dolog (": ", 2, 0, 0);
SAFE_FREE ();
}
int rtnval;
rtnval = emacs_close (dirp->dd_fd);
- xfree ((char *) dirp);
+ xfree (dirp);
return rtnval;
}
one utf16 word, so we cannot simply use the character
length of temp. */
int utf8_len = strlen (utf8_text);
- SAFE_ALLOCA (text, WCHAR *, (utf8_len + 1) * sizeof (WCHAR));
+ text = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR));
utf8to16 (utf8_text, utf8_len, text);
}
else
if (wv->key != NULL)
{
- SAFE_ALLOCA (out_string, char *,
- strlen (wv->name) + strlen (wv->key) + 2);
+ out_string = SAFE_ALLOCA (strlen (wv->name) + strlen (wv->key) + 2);
strcpy (out_string, wv->name);
strcat (out_string, "\t");
strcat (out_string, wv->key);
if (nlen > orig_len)
{
p = out_string;
- SAFE_ALLOCA (out_string, char *, nlen + 1);
+ out_string = SAFE_ALLOCA (nlen + 1);
q = out_string;
while (*p)
{
if (fuFlags & MF_OWNERDRAW)
utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR));
else
- SAFE_ALLOCA (utf16_string, WCHAR *, (utf8_len + 1) * sizeof (WCHAR));
+ utf16_string = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR));
utf8to16 (out_string, utf8_len, utf16_string);
return_value = unicode_append_menu (menu, fuFlags,
is invisible. >0 means lines indented more than this value are
invisible. */
it->selective = (INTEGERP (BVAR (current_buffer, selective_display))
- ? clip_to_bounds
- (-1, XINT (BVAR (current_buffer, selective_display)),
- PTRDIFF_MAX)
+ ? (clip_to_bounds
+ (-1, XINT (BVAR (current_buffer, selective_display)),
+ PTRDIFF_MAX))
: (!NILP (BVAR (current_buffer, selective_display))
? -1 : 0));
it->selective_display_ellipsis_p
msg = Fformat (3, args);
len = SBYTES (msg) + 1;
- SAFE_ALLOCA (buffer, char *, len);
+ buffer = SAFE_ALLOCA (len);
memcpy (buffer, SDATA (msg), len);
message_dolog (buffer, len - 1, 1, 0);
message_log_maybe_newline ();
if (STRINGP (m))
{
- char *buffer;
USE_SAFE_ALLOCA;
-
- SAFE_ALLOCA (buffer, char *, nbytes);
+ char *buffer = SAFE_ALLOCA (nbytes);
memcpy (buffer, SDATA (m), nbytes);
message_dolog (buffer, nbytes, 1, multibyte);
SAFE_FREE ();
#ifdef HAVE_NS
if (windows_or_buffers_changed
&& FRAME_NS_P (f))
- ns_set_doc_edited
+ ns_set_doc_edited
(f, Fbuffer_modified_p
(WVAR (XWINDOW (FVAR (f, selected_window)), buffer)));
#endif
selected_frame = frame;
/* Build desired tool-bar items from keymaps. */
- new_tool_bar = tool_bar_items
- (Fcopy_sequence (FVAR (f, tool_bar_items)), &new_n_tool_bar);
+ new_tool_bar
+ = tool_bar_items (Fcopy_sequence (FVAR (f, tool_bar_items)),
+ &new_n_tool_bar);
/* Redisplay the tool-bar if we changed it. */
if (new_n_tool_bar != f->n_tool_bar_items
font_descent = FONT_DESCENT (font) - boff;
font_height = FONT_HEIGHT (font);
- cmp->font = (void *) font;
+ cmp->font = font;
pcm = NULL;
if (! font_not_found_p)
static int
compare_fonts_by_sort_order (const void *v1, const void *v2)
{
- Lisp_Object font1 = *(Lisp_Object *) v1;
- Lisp_Object font2 = *(Lisp_Object *) v2;
+ Lisp_Object const *p1 = v1;
+ Lisp_Object const *p2 = v2;
+ Lisp_Object font1 = *p1;
+ Lisp_Object font2 = *p2;
int i;
for (i = 0; i < FONT_SIZE_INDEX; i++)
if (! success)
break;
- XFree ((char *) tmp_children);
+ XFree (tmp_children);
if (wm_window == rootw || had_errors)
break;
fatal ("Can't get proper X visual info");
dpyinfo->n_planes = vinfo->depth;
- XFree ((char *) vinfo);
+ XFree (vinfo);
}
}
if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0)
{
- char *str;
USE_SAFE_ALLOCA;
-
- SAFE_ALLOCA (str, char *, len);
+ char *str = SAFE_ALLOCA (len);
for (i = 0; i < len ; i++)
str[i] = XCHAR2B_BYTE2 (s->char2b + from + i);
BLOCK_INPUT;
TRACE1 ("RESTORE SELECTION EVENT %p", queue_tmp);
kbd_buffer_unget_event (&queue_tmp->event);
selection_queue = queue_tmp->next;
- xfree ((char *)queue_tmp);
+ xfree (queue_tmp);
}
}
\f
goto done;
/* This was allocated by Xlib, so use XFree. */
- XFree ((char *) tmp_data);
+ XFree (tmp_data);
if (*actual_type_ret == None || *actual_format_ret == 0)
goto done;
offset += bytes_gotten;
/* This was allocated by Xlib, so use XFree. */
- XFree ((char *) tmp_data);
+ XFree (tmp_data);
}
XFlush (display);
BLOCK_INPUT;
/* Use xfree, not XFree, because x_get_window_property
calls xmalloc itself. */
- xfree ((char *) data);
+ xfree (data);
UNBLOCK_INPUT;
receive_incremental_selection (display, window, property, target_type,
min_size_bytes, &data, &bytes,
/* Use xfree, not XFree, because x_get_window_property
calls xmalloc itself. */
- xfree ((char *) data);
+ xfree (data);
return val;
}
\f
if (rc == Success && actual != None)
{
unsigned long value = *(unsigned long *)data;
- XFree ((void *) data);
+ XFree (data);
if (value == opac)
{
x_uncatch_errors ();
dpyinfo->alt_mod_mask &= ~dpyinfo->meta_mod_mask;
}
- XFree ((char *) syms);
+ XFree (syms);
XFreeModifiermap (mods);
}