If I say calloc (1000, 23), does 23 "round" to 24? Or up to 32?

I was wondering, do most implementations calloctreat size as alignment, and round it to the next supported granularity?

If so, are they rounded to the next power of 2 or rounded to the next multiple of 8 or 16?

If it callockeeps the parameter the same, then how does it work? Won't your data be aligned?

Thank!

+3
source share
2 answers

sizeof - , , . , sizeof(foo) 23 foo, . ( , 23, , , , , .)

+5

, calloc(1000, 23) malloc(1000 * 23). "" - , 23000 . calloc ( , ).

23 24 calloc(1000, 23) 23000 24000 ( ). , 1000 .

+3

Source: https://habr.com/ru/post/1783323/


All Articles