From: Richard M. Stallman Date: Sun, 24 May 1998 23:24:25 +0000 (+0000) Subject: (shrink_regexp_cache): New function. X-Git-Tag: emacs-20.3~856 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6efc788795e564750837da362acf9326febc1ff1;p=emacs.git (shrink_regexp_cache): New function. --- diff --git a/src/search.c b/src/search.c index 175ae8a3f65..d9d445afad0 100644 --- a/src/search.c +++ b/src/search.c @@ -182,6 +182,23 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte) cp->regexp = Fcopy_sequence (pattern); } +/* Shrink each compiled regexp buffer in the cache + to the size actually used right now. + This is called from garbage collection. */ + +void +shrink_regexp_cache () +{ + struct regexp_cache *cp, **cpp; + + for (cp = searchbuf_head; cp != 0; cp = cp->next) + { + cp->buf.allocated = cp->buf.used; + cp->buf.buffer + = (unsigned char *) realloc (cp->buf.buffer, cp->buf.used); + } +} + /* Compile a regexp if necessary, but first check to see if there's one in the cache. PATTERN is the pattern to compile.