Sun, 24 Apr 2022 17:14:05 +0200
fix cxBufferMinimumCapacity implementation still using additional_bytes
src/buffer.c | file | annotate | diff | comparison | revisions |
--- a/src/buffer.c Sun Apr 24 16:23:44 2022 +0200 +++ b/src/buffer.c Sun Apr 24 17:14:05 2022 +0200 @@ -114,13 +114,10 @@ int cxBufferMinimumCapacity( CxBuffer *buffer, - size_t additional_bytes + size_t newcap ) { - size_t newcap = buffer->capacity + additional_bytes; - - // overflow protection - if (newcap < buffer->capacity) { - return -1; + if (newcap <= buffer->capacity) { + return 0; } unsigned char *newspace = realloc(buffer->bytes, newcap);