From: ceriel Date: Mon, 29 Jan 1990 11:41:37 +0000 (+0000) Subject: maintain own free list of buffer headers X-Git-Tag: release-5-5~1859 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0c4835caf38625e94d6d09da86b01258df8bfb3b;p=ack.git maintain own free list of buffer headers --- diff --git a/modules/src/input/inp_pkg.body b/modules/src/input/inp_pkg.body index 63abf90b8..061cffb2c 100644 --- a/modules/src/input/inp_pkg.body +++ b/modules/src/input/inp_pkg.body @@ -87,7 +87,7 @@ struct INP_i_buf { # endif not INP_READ_IN_ONE char *_ipp; -INP_PRIVATE struct INP_buffer_header *INP_head; +INP_PRIVATE struct INP_buffer_header *INP_head, *INP_free; #ifdef INP_READ_IN_ONE /* INP_rdfile() creates a buffer in which the text of the file @@ -162,7 +162,9 @@ INP_push_bh() bh->bh_i = INP_VAR; #endif INP_TYPE } - if (!(bh = (struct INP_buffer_header *)malloc(sizeof(struct INP_buffer_header)))) return 0; + bh = INP_free; + if (bh) INP_free = bh->bh_next; + else if (!(bh = (struct INP_buffer_header *)malloc(sizeof(struct INP_buffer_header)))) return 0; bh->bh_next = INP_head; bh->bh_eofreturned = 0; INP_head = bh; @@ -180,7 +182,8 @@ INP_pop_bh() bh = bh->bh_next; - free((char *) INP_head); + INP_head->bh_next = INP_free; + INP_free = INP_head; INP_head = bh; if (!bh) { /* no more entries */