aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2013-01-17 10:29:40 +0400
committerDmitry Antipov2013-01-17 10:29:40 +0400
commit468afbaceaeb045f69b1a47aa1550a2556cd7dfd (patch)
treeff5bd77d87a3f52802196d04ef4c6ca493c47fe7 /src/alloc.c
parent0e70695aa48cb34d8c3df6e4d4173b6adb474b23 (diff)
downloademacs-468afbaceaeb045f69b1a47aa1550a2556cd7dfd.tar.gz
emacs-468afbaceaeb045f69b1a47aa1550a2556cd7dfd.zip
* lisp.h (toplevel): Add comment about using Lisp_Save_Value
objects, related functions and macros. (make_save_value): Adjust prototype. (make_save_pointer): New prototype. (SAFE_NALLOCA): Fix indentation. Use make_save_pointer. (SAFE_ALLOCA_LISP): Adjust make_save_value usage. * alloc.c (format_save_value): Rename to make_save_value. (make_save_pointer): New function. (record_xmalloc): Use make_save_pointer. * dired.c, editfns.c, fileio.c, font.c, gtkutil.c, lread.c: * nsmenu.m, nsterm.m, xfns.c, xmenu.c, xselect.c, keymap.c: Change users of make_save_value to make_save_pointer. Likewise for format_save_value and make_save_value.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 7275a01bb73..a2e7282bb60 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -845,7 +845,7 @@ void *
845record_xmalloc (size_t size) 845record_xmalloc (size_t size)
846{ 846{
847 void *p = xmalloc (size); 847 void *p = xmalloc (size);
848 record_unwind_protect (safe_alloca_unwind, make_save_value (p, 0)); 848 record_unwind_protect (safe_alloca_unwind, make_save_pointer (p));
849 return p; 849 return p;
850} 850}
851 851
@@ -3356,7 +3356,7 @@ free_misc (Lisp_Object misc)
3356 and `o' for Lisp_Object. Up to 4 objects can be specified. */ 3356 and `o' for Lisp_Object. Up to 4 objects can be specified. */
3357 3357
3358Lisp_Object 3358Lisp_Object
3359format_save_value (const char *fmt, ...) 3359make_save_value (const char *fmt, ...)
3360{ 3360{
3361 va_list ap; 3361 va_list ap;
3362 int len = strlen (fmt); 3362 int len = strlen (fmt);
@@ -3404,15 +3404,19 @@ format_save_value (const char *fmt, ...)
3404 return val; 3404 return val;
3405} 3405}
3406 3406
3407/* Return a Lisp_Save_Value object containing POINTER and INTEGER. 3407/* The most common task it to save just one C pointer. */
3408 Most code should use this to package C integers and pointers
3409 to call record_unwind_protect. The unwind function can get the
3410 C values back using XSAVE_POINTER and XSAVE_INTEGER. */
3411 3408
3412Lisp_Object 3409Lisp_Object
3413make_save_value (void *pointer, ptrdiff_t integer) 3410make_save_pointer (void *pointer)
3414{ 3411{
3415 return format_save_value ("pi", pointer, integer); 3412 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3413 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3414
3415 p->area = 0;
3416 p->type0 = SAVE_POINTER;
3417 p->data[0].pointer = pointer;
3418 p->type1 = p->type2 = p->type3 = SAVE_UNUSED;
3419 return val;
3416} 3420}
3417 3421
3418/* Free a Lisp_Save_Value object. Do not use this function 3422/* Free a Lisp_Save_Value object. Do not use this function