mirror of
https://github.com/red0124/ssp.git
synced 2025-12-14 21:59:55 +01:00
[skip ci] Remove some magic numbers
This commit is contained in:
@@ -12,6 +12,7 @@ using string_range = std::pair<const char*, const char*>;
|
||||
using split_data = std::vector<string_range>;
|
||||
|
||||
constexpr inline auto default_delimiter = ",";
|
||||
constexpr static auto get_line_initial_buffer_size = 128;
|
||||
|
||||
template <bool StringError>
|
||||
inline void assert_string_error_defined() {
|
||||
@@ -46,7 +47,7 @@ inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
||||
}
|
||||
|
||||
if (*lineptr == nullptr) {
|
||||
*lineptr = static_cast<char*>(malloc(128));
|
||||
*lineptr = static_cast<char*>(malloc(get_line_initial_buffer_size));
|
||||
if (*lineptr == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -57,8 +58,8 @@ inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
||||
while (c != EOF) {
|
||||
if (pos + 1 >= *n) {
|
||||
size_t new_size = *n + (*n >> 2);
|
||||
if (new_size < 128) {
|
||||
new_size = 128;
|
||||
if (new_size < get_line_initial_buffer_size) {
|
||||
new_size = get_line_initial_buffer_size;
|
||||
}
|
||||
char* new_ptr = static_cast<char*>(
|
||||
realloc(static_cast<void*>(*lineptr), new_size));
|
||||
|
||||
Reference in New Issue
Block a user