-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop scratchbuf #239
base: master
Are you sure you want to change the base?
Drop scratchbuf #239
Commits on Nov 15, 2024
-
Extract the realloc from the size calculation so it can be shared with other upcoming callers. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for c6c2b55 - Browse repository at this point
Copy the full SHA c6c2b55View commit details -
Let the realloc happen in only one place, so we can change its behavior in future. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for f403b54 - Browse repository at this point
Copy the full SHA f403b54View commit details -
strbuf: Document strbuf_popchar(s)
Document the behavior for these functions and also clarify why the testsuite can check the buffer for equality after calling strbuf_str(). Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e206e42 - Browse repository at this point
Copy the full SHA e206e42View commit details -
strbuf: Invalidate (only) when stolen
The main for strbuf_steal() to free() on error was to allow the caller to pass the NULL up the stack with just a return call to strbuf_steal(). However this is error-prone and surprising that the buffer is still invalidated on error. Provide an strbuf cleanup attribute that can be used for the same purpose and make sure that when the string is stolen, it's set to NULL, so there's no dangling pointer around. Since we run the testsuite with AddressSanitizer, a simple test can be added to make sure the stolen string becomes valid when the attribute is used. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for d789707 - Browse repository at this point
Copy the full SHA d789707View commit details -
strbuf: Allow to start with stack space
This is the main functionality of the scratchbuf implementation: it starts with a buffer on stack that covers most of the calls, but also has a fallback to allocate the buffer if it grows beyond the initial size. Port that functionality from scratchbuf to strbuf, so the former can be eventually removed. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8979c7f - Browse repository at this point
Copy the full SHA 8979c7fView commit details -
strbuf: Add strbuf_reserve_extra()
To accomplish the same task as scratchbuf_alloc() does: make sure the buffer has enough space for next operations. One difference is that ensures **extra** space, not the total space. If needed in future, a strbuf_reserve(), that resembles C++'s std::vector::reserve(), can be added on top. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b90e5e8 - Browse repository at this point
Copy the full SHA b90e5e8View commit details -
strbuf: Do not append '\0' if not needed
Unconditionally appending '\0' is not a big problem, but that does trigger the buffer to potentially be re-allocated. Avoid that by checking the last char is not already NUL. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2d21d79 - Browse repository at this point
Copy the full SHA 2d21d79View commit details -
Wrapper for memcpy(). It's similar to strbuf_pushchars(), but push any char, including the NUL byte, relying on the size passed as argument. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 71ce083 - Browse repository at this point
Copy the full SHA 71ce083View commit details -
So users don't feel tempted to look at inside the strbuf. Just add a function for it and proper tests. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b4d3471 - Browse repository at this point
Copy the full SHA b4d3471View commit details -
strbuf: Add strbuf_shrink_to()
Useful when working with paths on a loop and resetting to a base path component on every loop iteration. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for aa26361 - Browse repository at this point
Copy the full SHA aa26361View commit details -
depmod: Convert depmod_modules_search_path() to strbuf
Replace the scratchbuf usage with corresponding API from strbuf. depmod_modules_search_path() itself may further be simplified in the future to share opening the dir with depmod_modules_search_dir(), but that is left for later. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 51875b9 - Browse repository at this point
Copy the full SHA 51875b9View commit details -
depmod: Convert output_symbols_bin() to strbuf
Remove last use of scratchbuf. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 9868d6c - Browse repository at this point
Copy the full SHA 9868d6cView commit details -
Remove scratchbuf implementation
All its unique features have been ported to strbuf and users converted. Nuke it. Signed-off-by: Lucas De Marchi <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 813bb1c - Browse repository at this point
Copy the full SHA 813bb1cView commit details