diff options
author | Daniel McArdle <dmcardle@chromium.org> | 2021-05-13 23:08:31 -0400 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2021-05-13 23:08:31 -0400 |
commit | de15165774db6a0964635ab9186943cab8cad42d (patch) | |
tree | 3774bd9ceb3cae6fc252e82b07bc86a5797d96ff | |
parent | 2d3f5dd294527974bd29f68f2a48bd58d09d1e9b (diff) | |
download | freetype2-de15165774db6a0964635ab9186943cab8cad42d.tar.gz |
[psaux] Use doubling allocation strategy for CF2_ArrStack.
Fixes timeout reported as
https://crbug.com/1206181
* src/psaux/psarrst.c (cf2_arrstack_{push,init}): Implement it.
* src/psaux/psarrst.h (CF2_ArrStackiRec): Drop `chunk'.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/psaux/psarrst.c | 5 | ||||
-rw-r--r-- | src/psaux/psarrst.h | 1 |
3 files changed, 13 insertions, 4 deletions
@@ -1,3 +1,14 @@ +2021-05-13 Daniel McArdle <dmcardle@chromium.org> + + [psaux] Use doubling allocation strategy for CF2_ArrStack. + + Fixes timeout reported as + + https://crbug.com/1206181 + + * src/psaux/psarrst.c (cf2_arrstack_{push,init}): Implement it. + * src/psaux/psarrst.h (CF2_ArrStackiRec): Drop `chunk'. + 2021-05-12 Alexei Podtelezhnikov <apodtele@gmail.com> * src/smooth/ftgrays.c (FT_MAX_GRAY_SPANS): Increase from 10 to 16. diff --git a/src/psaux/psarrst.c b/src/psaux/psarrst.c index 7f27c2484..70313d283 100644 --- a/src/psaux/psarrst.c +++ b/src/psaux/psarrst.c @@ -65,7 +65,6 @@ arrstack->error = error; arrstack->sizeItem = sizeItem; arrstack->allocated = 0; - arrstack->chunk = 10; /* chunks of 10 items */ arrstack->count = 0; arrstack->totalSize = 0; arrstack->ptr = NULL; @@ -216,9 +215,9 @@ if ( arrstack->count == arrstack->allocated ) { - /* grow the buffer by one chunk */ + /* increase the buffer size */ if ( !cf2_arrstack_setNumElements( - arrstack, arrstack->allocated + arrstack->chunk ) ) + arrstack, arrstack->allocated * 2 + 16 ) ) { /* on error, ignore the push */ return; diff --git a/src/psaux/psarrst.h b/src/psaux/psarrst.h index 098617b25..31e5330cc 100644 --- a/src/psaux/psarrst.h +++ b/src/psaux/psarrst.h @@ -55,7 +55,6 @@ FT_BEGIN_HEADER size_t sizeItem; /* bytes per element */ size_t allocated; /* items allocated */ - size_t chunk; /* allocation increment in items */ size_t count; /* number of elements allocated */ size_t totalSize; /* total bytes allocated */ |