Thread: How to guarantee alignment with malloc and or new?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Alessio Stella
    Join Date
    May 2008
    Location
    Italy, Bologna
    Posts
    251

    Post How to guarantee alignment with malloc and or new?

    How can I impose alignment of data wit malloc and / or new?
    Guess
    Code:
    if (sizeof(data)%alignment)
       data=(data*)malloc(alignment*(sizeof(data)/alignment)+alignment)
    else data=(data*)malloc(sizeof(data));
    ??


    With new??
    Last edited by mynickmynick; 08-26-2008 at 07:58 AM.

Popular pages Recent additions subscribe to a feed