aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2012-08-03 16:36:11 -0700
committerPaul Eggert2012-08-03 16:36:11 -0700
commit98c6f1e36ff487925280fa0b0340af9d058632b5 (patch)
tree5601a2ac9433883b753a36f8d9c15f9d9d0b0eec /src/alloc.c
parent8834c57aab03fb7ea9d92f9e995844ff7ce64b7b (diff)
downloademacs-98c6f1e36ff487925280fa0b0340af9d058632b5.tar.gz
emacs-98c6f1e36ff487925280fa0b0340af9d058632b5.zip
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.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/alloc.c b/src/alloc.c
index aef68a1c070..3939e704978 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -898,6 +898,16 @@ safe_alloca_unwind (Lisp_Object arg)
898 return Qnil; 898 return Qnil;
899} 899}
900 900
901/* Return a newly allocated memory block of SIZE bytes, remembering
902 to free it when unwinding. */
903void *
904record_xmalloc (size_t size)
905{
906 void *p = xmalloc (size);
907 record_unwind_protect (safe_alloca_unwind, make_save_value (p, 0));
908 return p;
909}
910
901 911
902/* Like malloc but used for allocating Lisp data. NBYTES is the 912/* Like malloc but used for allocating Lisp data. NBYTES is the
903 number of bytes to allocate, TYPE describes the intended use of the 913 number of bytes to allocate, TYPE describes the intended use of the
@@ -5210,13 +5220,11 @@ make_pure_string (const char *data,
5210 ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) 5220 ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte)
5211{ 5221{
5212 Lisp_Object string; 5222 Lisp_Object string;
5213 struct Lisp_String *s; 5223 struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
5214
5215 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
5216 s->data = (unsigned char *) find_string_data_in_pure (data, nbytes); 5224 s->data = (unsigned char *) find_string_data_in_pure (data, nbytes);
5217 if (s->data == NULL) 5225 if (s->data == NULL)
5218 { 5226 {
5219 s->data = (unsigned char *) pure_alloc (nbytes + 1, -1); 5227 s->data = pure_alloc (nbytes + 1, -1);
5220 memcpy (s->data, data, nbytes); 5228 memcpy (s->data, data, nbytes);
5221 s->data[nbytes] = '\0'; 5229 s->data[nbytes] = '\0';
5222 } 5230 }
@@ -5234,9 +5242,7 @@ Lisp_Object
5234make_pure_c_string (const char *data, ptrdiff_t nchars) 5242make_pure_c_string (const char *data, ptrdiff_t nchars)
5235{ 5243{
5236 Lisp_Object string; 5244 Lisp_Object string;
5237 struct Lisp_String *s; 5245 struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
5238
5239 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
5240 s->size = nchars; 5246 s->size = nchars;
5241 s->size_byte = -1; 5247 s->size_byte = -1;
5242 s->data = (unsigned char *) data; 5248 s->data = (unsigned char *) data;
@@ -5251,10 +5257,8 @@ make_pure_c_string (const char *data, ptrdiff_t nchars)
5251Lisp_Object 5257Lisp_Object
5252pure_cons (Lisp_Object car, Lisp_Object cdr) 5258pure_cons (Lisp_Object car, Lisp_Object cdr)
5253{ 5259{
5254 register Lisp_Object new; 5260 Lisp_Object new;
5255 struct Lisp_Cons *p; 5261 struct Lisp_Cons *p = pure_alloc (sizeof *p, Lisp_Cons);
5256
5257 p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons);
5258 XSETCONS (new, p); 5262 XSETCONS (new, p);
5259 XSETCAR (new, Fpurecopy (car)); 5263 XSETCAR (new, Fpurecopy (car));
5260 XSETCDR (new, Fpurecopy (cdr)); 5264 XSETCDR (new, Fpurecopy (cdr));
@@ -5267,10 +5271,8 @@ pure_cons (Lisp_Object car, Lisp_Object cdr)
5267static Lisp_Object 5271static Lisp_Object
5268make_pure_float (double num) 5272make_pure_float (double num)
5269{ 5273{
5270 register Lisp_Object new; 5274 Lisp_Object new;
5271 struct Lisp_Float *p; 5275 struct Lisp_Float *p = pure_alloc (sizeof *p, Lisp_Float);
5272
5273 p = (struct Lisp_Float *) pure_alloc (sizeof *p, Lisp_Float);
5274 XSETFLOAT (new, p); 5276 XSETFLOAT (new, p);
5275 XFLOAT_INIT (new, num); 5277 XFLOAT_INIT (new, num);
5276 return new; 5278 return new;
@@ -5284,10 +5286,8 @@ static Lisp_Object
5284make_pure_vector (ptrdiff_t len) 5286make_pure_vector (ptrdiff_t len)
5285{ 5287{
5286 Lisp_Object new; 5288 Lisp_Object new;
5287 struct Lisp_Vector *p;
5288 size_t size = header_size + len * word_size; 5289 size_t size = header_size + len * word_size;
5289 5290 struct Lisp_Vector *p = pure_alloc (size, Lisp_Vectorlike);
5290 p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike);
5291 XSETVECTOR (new, p); 5291 XSETVECTOR (new, p);
5292 XVECTOR (new)->header.size = len; 5292 XVECTOR (new)->header.size = len;
5293 return new; 5293 return new;