Quantcast
Channel: How to allocate aligned memory only using the standard library? - Stack Overflow
Viewing all articles
Browse latest Browse all 18

Answer by stackguy for How to allocate aligned memory only using the standard library?

$
0
0
size =1024;
alignment = 16;
aligned_size = size +(alignment -(size %  alignment));
mem = malloc(aligned_size);
memset_16aligned(mem, 0, 1024);
free(mem);

Hope this one is the simplest implementation, let me know your comments.


Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>