Zero clue where that change appeared from magically

This commit is contained in:
EmeraldLockdown 2026-03-19 19:27:41 -05:00
parent 6cb0ace049
commit 7ffe8a12a2

View file

@ -550,7 +550,7 @@ void str_seperator_concat(char *output_buffer, int buffer_size, char** strings,
memset(output_buffer, 0, buffer_size);
if (num_strings <= 0) { return; }
// calculate the total length of all strings
// Calculate the total length of all strings
int string_length[num_strings];
int total_length = 0;
for (int i = 0; i < num_strings; i++) {
@ -562,7 +562,7 @@ void str_seperator_concat(char *output_buffer, int buffer_size, char** strings,
int seperator_length = strlen(seperator);
int seperators_length = (num_strings - 1) * seperator_length;
if (seperators_length + 8 < buffer_size) {
// shorten the largest string over and over until we fit
// Shorten the largest string over and over until we fit
while (total_length + seperators_length >= buffer_size) {
int* largest = NULL;
for (int i = 0; i < num_strings; i++) {
@ -576,16 +576,16 @@ void str_seperator_concat(char *output_buffer, int buffer_size, char** strings,
}
}
// fill the buffer
// Fill the buffer
int buffer_index = 0;
for (int i = 0; i < num_strings; i++) {
// concat string
// Concat string
int amount = MIN(buffer_size - buffer_index, string_length[i] + 1);
if (amount <= 0) { break; }
snprintf(&output_buffer[buffer_index], amount, "%s", strings[i]);
buffer_index += string_length[i];
// concat seperator
// Concat seperator
if (i != (num_strings - 1)) {
int amount = MIN(buffer_size - buffer_index, seperator_length + 1);
if (amount <= 0) { break; }
@ -593,6 +593,4 @@ void str_seperator_concat(char *output_buffer, int buffer_size, char** strings,
buffer_index += seperator_length;
}
}
output_buffer += buffer_index;
}
}