Use binary units for sizes, not decimal values.
KiB = 1024 bytes
MiB = 1024 * 1024 bytes
GiB = 1024 * 1024 * 1024 bytes
Please be aware, I am no C programmer. I also saw some use of Mb and mb,
which might indicate Megabit.
Please double check if my assumptions are correct.
Reference:
https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
If the desire is to use decimal units like KB, MB and GB,
the code would need to be changed to use 1000 for kilo.
That is way over my head and not a good task for me.