[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/record 9122e24 12/13: Signal errors from APIs.
From: |
Lars Brinkhoff |
Subject: |
[Emacs-diffs] scratch/record 9122e24 12/13: Signal errors from APIs. |
Date: |
Mon, 20 Mar 2017 16:11:10 -0400 (EDT) |
branch: scratch/record
commit 9122e2415dfe4e20ed30c30c23acdd340250fcc2
Author: Lars Brinkhoff <address@hidden>
Commit: Lars Brinkhoff <address@hidden>
Signal errors from APIs.
---
src/alloc.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/alloc.c b/src/alloc.c
index 1a3a38e..d46f2a7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3393,11 +3393,14 @@ allocate_buffer (void)
}
+/* Allocate a new record with COUNT slots. Return NULL if COUNT is
+ too large. */
+
static struct Lisp_Vector *
allocate_record (int count)
{
if (count >= (1 << PSEUDOVECTOR_SIZE_BITS))
- error ("Record too large");
+ return NULL;
struct Lisp_Vector *p = allocate_vector (count);
XSETPVECTYPE (p, PVEC_RECORD);
@@ -3421,6 +3424,10 @@ type slot, must fit in PSEUDOVECTOR_SIZE_BITS. */)
size = XFASTINT (slots) + 1;
p = allocate_record (size);
+ if (p == NULL)
+ error ("Attempt to allocate a record of %ld slots; max is %d",
+ size, (1 << PSEUDOVECTOR_SIZE_BITS) - 1);
+
p->contents[0] = type;
for (i = 1; i < size; i++)
p->contents[i] = init;
@@ -3440,6 +3447,10 @@ usage: (record TYPE &rest SLOTS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
struct Lisp_Vector *p = allocate_record (nargs);
+ if (p == NULL)
+ error ("Attempt to allocate a record of %ld slots; max is %d",
+ nargs, (1 << PSEUDOVECTOR_SIZE_BITS) - 1);
+
Lisp_Object type = args[0];
Lisp_Object record;
@@ -3460,6 +3471,10 @@ DEFUN ("copy-record", Fcopy_record, Scopy_record, 1, 1,
0,
struct Lisp_Vector *src = XVECTOR (record);
ptrdiff_t size = ASIZE (record) & PSEUDOVECTOR_SIZE_MASK;
struct Lisp_Vector *new = allocate_record (size);
+ if (new == NULL)
+ error ("Attempt to allocate a record of %ld slots; max is %d",
+ size, (1 << PSEUDOVECTOR_SIZE_BITS) - 1);
+
memcpy (&(new->contents[0]), &(src->contents[0]),
size * sizeof (Lisp_Object));
XSETVECTOR (record, new);
- [Emacs-diffs] branch scratch/record created (now dbb4691), Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 457791b 04/13: Test cases., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 29d7fef 03/13: Make EIEIO use records., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record fff19c5 06/13: Use sizeof to get length of cl-struct prefix., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 6450a4c 07/13: Better doc string for `old-struct-compat'., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 953ceab 10/13: Fix cl-print-object to find the object class the new way., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 18e3aac 01/13: Add record objects with user-defined types., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record f6e4882 11/13: Make a note that CHECK_RECORD_TYPE is a work in progress., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 9122e24 12/13: Signal errors from APIs.,
Lars Brinkhoff <=
- [Emacs-diffs] scratch/record be8079b 05/13: Backward compatibility with pre-existing struct instances., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 91584a7 09/13: Make it possible to compare records with `equal'., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record dbb4691 13/13: Enable legacy defstruct compatibility., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record db8ff08 08/13: Better doc strings for `make-record', `record', and `copy-record'., Lars Brinkhoff, 2017/03/20
- [Emacs-diffs] scratch/record 5d4f89f 02/13: Update cl-defstruct to use records., Lars Brinkhoff, 2017/03/20