Configurable UTSTRING_INITIAL_SIZE - #146
Conversation
|
|
||
| #ifndef UTSTRING_INITIAL_SIZE | ||
| #define UTSTRING_INITIAL_SIZE 0x64 | ||
| #endif |
There was a problem hiding this comment.
(A) If somebody has a strong use-case for tweaking this specific parameter (UTSTRING_INITIAL_SIZE), then I might be swayed; but a priori, I'd rather see this particular diff come as part of a larger, comprehensive thinking-out of utstring's allocation machinery. Like, maybe it should be using a primitive such as utstring_realloc that the user is allowed to -Define, and maybe we need to think about what realloc-of-size-zero means, and so on.
(B) Writing 0x64 when you mean 100 is just as confusing as writing 0100 when you mean 64. I don't know why you'd do that.
There was a problem hiding this comment.
(A) 1. On embedded systems (e.g: an AVR/PIC with just 512 of RAM), the programmer could choose a value smaller than 100; On common fast systems, it can be increased (1 kB, 8 kB) via building system.
(B) Oops, sorry. It was just a habit from microcontroller coding! 😅
There was a problem hiding this comment.
(B) additional info: It uses the same concept: https://github.com/troydhanson/libut/blob/master/src/utvector.c#L29 . (however INITIAL_SIZE should be prefixed to UTVECTOR_INITIAL_SIZE avoiding to conflict on user macros)
| s = (UT_string*)malloc(sizeof(UT_string)); \ | ||
| if (!s) oom(); \ | ||
| (s) = (UT_string*)malloc(sizeof(UT_string)); \ | ||
| if (!(s)) oom(); \ |
No description provided.