diff options
| author | Paul Eggert | 2019-04-01 11:54:23 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-04-01 12:02:37 -0700 |
| commit | 74b63d27a629db96b73a83f205d8a256911abc1c (patch) | |
| tree | 2c2128596c370b9c05f5e80d7805137426d35be1 /src/data.c | |
| parent | 9287813da1ae9076f29be111674d1795bee66447 (diff) | |
| download | emacs-74b63d27a629db96b73a83f205d8a256911abc1c.tar.gz emacs-74b63d27a629db96b73a83f205d8a256911abc1c.zip | |
Make struct Lisp_Objfwd etc. objects read-only
Initialize these objects statically, and make them constants.
This is a bit safer and more efficient.
* src/data.c (XBOOLFWD, XKBOARD_OBJFWD, XFIXNUMFWD, XOBJFWD):
* src/lisp.h (XBUFFER_OBJFWD):
Return a pointer-to-const instead of an unrestricted pointer.
(lispfwd): fwdptr is now a pointer-to-const instead of an
unrestricted pointer. All uses changed.
(SET_SYMBOL_FWD): Accept pointer-to-const instead of an
unrestricted pointer.
(DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_BOOL, DEFVAR_INT)
(DEFVAR_KBOARD): Initialize static structures statically
instead of dynamically, and make them const.
* src/lread.c (defvar_int, defvar_bool, defvar_lisp_nopro)
(defvar_lisp, defvar_kboard): Accept pointer-to-const instead
of an unrestricted pointer; it’s now the caller’s
responsibility to initialize the pointed-to storage. No need
for a separate address argument any more. All callers
changed.
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/data.c b/src/data.c index 936bb74f69a..11cd598ed85 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -62,25 +62,25 @@ OBJFWDP (lispfwd a) | |||
| 62 | return XFWDTYPE (a) == Lisp_Fwd_Obj; | 62 | return XFWDTYPE (a) == Lisp_Fwd_Obj; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | static struct Lisp_Boolfwd * | 65 | static struct Lisp_Boolfwd const * |
| 66 | XBOOLFWD (lispfwd a) | 66 | XBOOLFWD (lispfwd a) |
| 67 | { | 67 | { |
| 68 | eassert (BOOLFWDP (a)); | 68 | eassert (BOOLFWDP (a)); |
| 69 | return a.fwdptr; | 69 | return a.fwdptr; |
| 70 | } | 70 | } |
| 71 | static struct Lisp_Kboard_Objfwd * | 71 | static struct Lisp_Kboard_Objfwd const * |
| 72 | XKBOARD_OBJFWD (lispfwd a) | 72 | XKBOARD_OBJFWD (lispfwd a) |
| 73 | { | 73 | { |
| 74 | eassert (KBOARD_OBJFWDP (a)); | 74 | eassert (KBOARD_OBJFWDP (a)); |
| 75 | return a.fwdptr; | 75 | return a.fwdptr; |
| 76 | } | 76 | } |
| 77 | static struct Lisp_Intfwd * | 77 | static struct Lisp_Intfwd const * |
| 78 | XFIXNUMFWD (lispfwd a) | 78 | XFIXNUMFWD (lispfwd a) |
| 79 | { | 79 | { |
| 80 | eassert (INTFWDP (a)); | 80 | eassert (INTFWDP (a)); |
| 81 | return a.fwdptr; | 81 | return a.fwdptr; |
| 82 | } | 82 | } |
| 83 | static struct Lisp_Objfwd * | 83 | static struct Lisp_Objfwd const * |
| 84 | XOBJFWD (lispfwd a) | 84 | XOBJFWD (lispfwd a) |
| 85 | { | 85 | { |
| 86 | eassert (OBJFWDP (a)); | 86 | eassert (OBJFWDP (a)); |