Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Aligned malloc on cygwin (Tord)

Author: Robert Hyatt

Date: 08:34:26 02/18/05

Go up one level in this thread


On February 18, 2005 at 10:50:12, Anthony Cozzie wrote:

>Does anyone know a syscall to get aligned memory from Cygwin?  I use
>posix_memalign on unix and __aligned_malloc on windows, but neither of those
>seem to work.  There is a memalign() function in malloc.h that claims to work,
>but it returns 0x400000 (isn't that the address of the text segment?) and Zappa
>crashes instantly.
>
>Other than that cygwin appears to be working.
>
>anthony


This works:

p=malloc(size+15)
p=(P+15) & 0xfffffff0;

:)

makes p point to an address that is a multiple of 16.  If it already does, it
does nothing.  Worst case is to lose 15 bytes of memory as a result.  You should
save the original p if you want to free(p) later...



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.