surf-adblock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3004f1865b45afbaac4bc0711dc643675315982a
parent 95c5c0d4bd55049c2fbf2eff49580076ac749023
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sun, 17 Jul 2016 16:15:31 +0200

change the names in String for more clarity

Adapt the names in string_buffer_realloc() too

Diffstat:
surf-adblock.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/surf-adblock.c b/surf-adblock.c @@ -17,8 +17,8 @@ /* String data / memory pool */ typedef struct string { char *data; /* data */ - size_t len; /* string length */ - size_t bufsiz; /* allocated size */ + size_t datasz; /* allocated size */ + size_t len; /* current string length */ } String; typedef struct Page { @@ -138,13 +138,13 @@ eprintf(const char *fmt, ...) } static void -string_buffer_realloc(String *s, size_t newlen) +string_buffer_realloc(String *s, size_t newsz) { - size_t alloclen; + size_t allocsz; - for (alloclen = 64; alloclen <= newlen; alloclen *= 2) + for (allocsz = 64; allocsz <= newsz; allocsz *= 2) ; - if (!(s->data = realloc(s->data, alloclen))) + if (!(s->data = realloc(s->data, allocsz))) eprintf("realloc: %s\n", strerror(errno)); s->bufsiz = alloclen; } @@ -155,8 +155,8 @@ string_append(String *s, const char *data, size_t len) if (!len) return; /* check if allocation is necesary, don't shrink buffer, - * should be more than bufsiz ofcourse. */ - if (s->len + len >= s->bufsiz) + * should be more than datasz ofcourse. */ + if (s->len + len >= s->datasz) string_buffer_realloc(s, s->len + len + 1); memcpy(s->data + s->len, data, len); s->len += len;