diff options
author | Greg McGary <greg@mcgary.org> | 2000-07-07 07:53:40 +0000 |
---|---|---|
committer | Greg McGary <greg@mcgary.org> | 2000-07-07 07:53:40 +0000 |
commit | 8ccd2cb1910a239087f41dd1e90c89e675232239 (patch) | |
tree | bd6f98c237d74a16822412fc2e53d273655c86dd /posix/regex.c | |
parent | 89a4f6ff1f643aadc4d3e9e401d792b5198d9f52 (diff) | |
download | glibc-8ccd2cb1910a239087f41dd1e90c89e675232239.zip glibc-8ccd2cb1910a239087f41dd1e90c89e675232239.tar.gz glibc-8ccd2cb1910a239087f41dd1e90c89e675232239.tar.bz2 |
* posix/regex.c (EXTEND_BUFFER): Compute increment once.
Move all three components of a bounded pointer.
2000-07-07 Greg McGary <greg@mcgary.org>
* posix/regex.c (EXTEND_BUFFER): Compute increment once.
Move all three components of a bounded pointer.
Diffstat (limited to 'posix/regex.c')
-rw-r--r-- | posix/regex.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/posix/regex.c b/posix/regex.c index 0af5283..c9476be 100644 --- a/posix/regex.c +++ b/posix/regex.c @@ -1747,28 +1747,35 @@ static reg_errcode_t compile_range _RE_ARGS ((unsigned int range_start, reset the pointers that pointed into the old block to point to the correct places in the new one. If extending the buffer results in it being larger than MAX_BUF_SIZE, then flag memory exhausted. */ +#if __BOUNDED_POINTERS__ +# define MOVE_BUFFER_POINTER(P) \ + (__ptrlow (P) += incr, __ptrhigh (P) += incr, __ptrvalue (P) += incr) +#else +# define MOVE_BUFFER_POINTER(P) (P) += incr +#endif #define EXTEND_BUFFER() \ - do { \ + do { \ unsigned char *old_buffer = bufp->buffer; \ - if (bufp->allocated == MAX_BUF_SIZE) \ + if (bufp->allocated == MAX_BUF_SIZE) \ return REG_ESIZE; \ bufp->allocated <<= 1; \ if (bufp->allocated > MAX_BUF_SIZE) \ - bufp->allocated = MAX_BUF_SIZE; \ + bufp->allocated = MAX_BUF_SIZE; \ bufp->buffer = (unsigned char *) REALLOC (bufp->buffer, bufp->allocated);\ if (bufp->buffer == NULL) \ return REG_ESPACE; \ /* If the buffer moved, move all the pointers into it. */ \ if (old_buffer != bufp->buffer) \ { \ - b = (b - old_buffer) + bufp->buffer; \ - begalt = (begalt - old_buffer) + bufp->buffer; \ - if (fixup_alt_jump) \ - fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ - if (laststart) \ - laststart = (laststart - old_buffer) + bufp->buffer; \ - if (pending_exact) \ - pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ + int incr = bufp->buffer - old_buffer; \ + MOVE_BUFFER_POINTER (b); \ + MOVE_BUFFER_POINTER (begalt); \ + if (fixup_alt_jump) \ + MOVE_BUFFER_POINTER (fixup_alt_jump); \ + if (laststart) \ + MOVE_BUFFER_POINTER (laststart); \ + if (pending_exact) \ + MOVE_BUFFER_POINTER (pending_exact); \ } \ } while (0) |