File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,18 +61,20 @@ int buffer_free(buffer_t buffer) {
6161/* Grow `buffer` to at least `min_length`.
6262 * Return non-zero on allocation failure. */
6363static int buffer_grow (buffer_t buffer , int min_length ) {
64+ int old_size = 0 ;
6465 int size = buffer -> size ;
6566 char * old_buffer = buffer -> buffer ;
6667 if (size >= min_length ) {
6768 return 0 ;
6869 }
6970 while (size < min_length ) {
70- int old_size = size ;
71+ old_size = size ;
7172 size *= 2 ;
7273 if (size <= old_size ) {
73- /* size did not increase. Could be an overflow or size < 1. Just go with min_length */
74+ /* Size did not increase. Could be an overflow
75+ * or size < 1. Just go with min_length. */
7476 size = min_length ;
75- }
77+ }
7678 }
7779 buffer -> buffer = (char * )realloc (buffer -> buffer , sizeof (char ) * size );
7880 if (buffer -> buffer == NULL ) {
You can’t perform that action at this time.
0 commit comments