[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scratch_buffer and 'void *' pointer arithmetic
From: |
Bruno Haible |
Subject: |
Re: scratch_buffer and 'void *' pointer arithmetic |
Date: |
Sat, 16 Dec 2017 06:03:13 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-101-generic; KDE/5.18.0; x86_64; ; ) |
I wrote:
> struct scratch_buffer {
> void *data; /* Pointer to the beginning of the scratch area. */
> size_t length; /* Allocated space at the data pointer, in bytes. */
> ...
> };
>
> it seems quite natural to do pointer arithmetic on 'data'. Namely, this will
> happen each time a scratch_buffer gets booked by several (not just one)
> pieces of memory.
Oops. scratch_buffer is not appropriate for this kind of use, as it does
not contain a 'size_t used;' field (like linebuffer does).
I was thinking at a combination between scratch_buffer and the 'alloca_used'
logic from glob.c. But this is beyond what scratch_buffer does.
Bruno