What is the replacement in C++ for _aligned_malloc in C?

A

Amal P

Hi,

I want to allocate some memory 16Byte aligned. For this now I am
using _aligned_malloc function that is given in malloc.h. What is the
substitute for this in new ? Is there any way to allocate aligned
memory using new ?

Thanks and Regards,
Amal P.
 
J

Jakob Bieling

Amal P said:
I want to allocate some memory 16Byte aligned. For this now I am
using _aligned_malloc function that is given in malloc.h. What is the
substitute for this in new ? Is there any way to allocate aligned
memory using new ?


_aligned_malloc is not a Standard function, but rather an extension
provided by your implementation. You should probably continue using that
extension function.

regards
 
N

Neo

You can take a look at this usage of new called
"placement new"...

new (placement_addr) type;

where placement_addr is compulsorily a pointer!

But yes, you need to say delete placement_addr & not the type pointer
used in "new".


--with regards
Neo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top