Introduction
Introduction Statistics Contact Development Disclaimer Help
different scaling for memory allocation - json2tsv - JSON to TSV converter
git clone git://git.codemadness.org/json2tsv
Log
Files
Refs
README
LICENSE
---
commit f8704af3ceec42fb7be10caca4392c85f82631eb
parent dfd26e7ccf4f83f4c140503b69d773b1dbb81808
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 15 Oct 2019 18:43:56 +0200
different scaling for memory allocation
greedier for large strings, much less memory for smaller ones
Diffstat:
M json2tsv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/json2tsv.c b/json2tsv.c
@@ -87,10 +87,10 @@ capacity(char **value, size_t *sz, size_t cur, size_t inc)
need = cur + inc;
if (need > *sz) {
- if (need > SIZE_MAX - 4096) {
+ if (need > SIZE_MAX / 2) {
newsiz = SIZE_MAX;
} else {
- for (newsiz = *sz; newsiz < need; newsiz += 4096)
+ for (newsiz = *sz < 64 ? 64 : *sz; newsiz <= need; new…
;
}
if (!(newp = realloc(*value, newsiz)))
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.