1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

Added assertion test for the buffer alignment padding size.

This commit is contained in:
Olaf Barthel
2023-09-06 13:22:07 +02:00
parent e4a703000a
commit 45d118101a

View File

@ -125,6 +125,8 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size)
allocate some memory for it. */ allocate some memory for it. */
if(size > 0 && buf == NULL) if(size > 0 && buf == NULL)
{ {
assert( size <= ((size + (__cache_line_size-1)) & ~(__cache_line_size-1)) );
/* Allocate a little more memory than necessary. */ /* Allocate a little more memory than necessary. */
new_buffer = malloc(size + (__cache_line_size-1)); new_buffer = malloc(size + (__cache_line_size-1));
if(new_buffer == NULL) if(new_buffer == NULL)