From 4b0e44fc728df2f5d40b7e15a5b490b001503bbb Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 17 Aug 2002 04:53:57 +0000 Subject: [PATCH] (overlays_at): Handle extending vec uniformly. (overlays_in): Handle extending vec from length 0 as in overlays_at. --- src/buffer.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 7af8dbc334c..d1ee97c1924 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2498,9 +2498,11 @@ overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) { if (extend) { - *len_ptr = len *= 2; + /* Make it work with an initial len == 0. */ + len *= 2; if (len == 0) - len = *len_ptr = 4; + len = 4; + *len_ptr = len; vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); *vec_ptr = vec; } @@ -2594,7 +2596,11 @@ overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr) Either make it bigger, or don't store any more in it. */ if (extend) { - *len_ptr = len *= 2; + /* Make it work with an initial len == 0. */ + len *= 2; + if (len == 0) + len = 4; + *len_ptr = len; vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); *vec_ptr = vec; } @@ -2638,7 +2644,11 @@ overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr) { if (extend) { - *len_ptr = len *= 2; + /* Make it work with an initial len == 0. */ + len *= 2; + if (len == 0) + len = 4; + *len_ptr = len; vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); *vec_ptr = vec; } -- 2.39.5