Created
January 21, 2017 20:06
-
-
Save Cactus64k/bc4f63ca99ab3a747397651f72895467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void strcat_realloc(char** buff, char* str, intmax_t str_len, intmax_t* buff_size, intmax_t* buff_pos) | |
{ | |
assert(buff != NULL); | |
assert(str != NULL); | |
assert(buff_size != NULL); | |
assert(buff_pos != NULL); | |
if(*buff_size - *buff_pos - 1 > str_len) | |
{ | |
strcat(*buff, str); | |
*buff_pos = *buff_pos + str_len; | |
} | |
else | |
{ | |
*buff_size = *buff_size * 2; | |
*buff = realloc(*buff, *buff_size); | |
strcat_realloc(buff, str, str_len, buff_size, buff_pos); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment