On 4/30/20 3:10 PM, Daniel Stenberg via curl-library wrote:
Hi team,

In PR 5300 I'm introducing a library-wide change that I wanted to make you all aware of!


# Feedback?

I think there is also the sequence at https://github.com/curl/curl/blob/master/packages/OS400/ccsidcurl.c#L855 that could be transformed, although array elements are not characters. Other realloc calls in OS400 code only shrink buffers to spare memory.


Suggestions:

- Implement auto shrink when shortening data under an arbitrary watermark, for example 20% of the allocated memory.

- A function to grow allocation without initializing it: something like (conceptually) accepting Curl_dyn_addn(&dbuf, NULL, size), maybe returning a pointer to the extended memory block. The motivation is: in some circonstances, OS400 does not like moving pointers as characters; if the dynamic array element contains a pointer, it may lose its addressing capability after byte to byte copy, thus a direct access to the allocated block is required for proper initialisation. This would also be useful to allocate a buffer when the final data size is unknown (before a read, for example).

- Curl_dyn_head(): opposite of Curl_dyn_tail(), keeping the leading bytes. Although very simple to perform without such a function, it'll add implementation details abstraction.

- In debug mode, store DYNINIT also after the data and check it: this may detect buffer overflows. This could also be done before the data, but beware of alignement.

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Reply via email to