Mercurial > emacs
changeset 34359:09d0a988515c
(current_minor_maps): Use malloc. Prevent a leak.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 08 Dec 2000 09:58:28 +0000 |
parents | aa3b69684dbf |
children | c6d74397e65f |
files | src/keymap.c |
diffstat | 1 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/keymap.c Fri Dec 08 09:58:04 2000 +0000 +++ b/src/keymap.c Fri Dec 08 09:58:28 2000 +0000 @@ -1162,16 +1162,18 @@ { Lisp_Object *newmodes, *newmaps; + /* Use malloc/realloc here. See the comment above + this function. */ if (cmm_maps) { BLOCK_INPUT; cmm_size *= 2; newmodes = (Lisp_Object *) realloc (cmm_modes, - cmm_size * sizeof (Lisp_Object)); + cmm_size * sizeof *newmodes); newmaps = (Lisp_Object *) realloc (cmm_maps, - cmm_size * sizeof (Lisp_Object)); + cmm_size * sizeof *newmaps); UNBLOCK_INPUT; } else @@ -1179,18 +1181,18 @@ BLOCK_INPUT; cmm_size = 30; newmodes - = (Lisp_Object *) xmalloc (cmm_size * sizeof (Lisp_Object)); + = (Lisp_Object *) malloc (cmm_size * sizeof *newmodes); newmaps - = (Lisp_Object *) xmalloc (cmm_size * sizeof (Lisp_Object)); + = (Lisp_Object *) malloc (cmm_size * sizeof *newmaps); UNBLOCK_INPUT; } - if (newmaps && newmodes) - { - cmm_modes = newmodes; - cmm_maps = newmaps; - } - else + if (newmodes) + cmm_modes = newmodes; + if (newmaps) + cmm_maps = newmaps; + + if (newmodes == NULL || newmaps == NULL) break; }