I wrote a simple program using memalign().
(BTW the documentation of memalign() doesn’t match the prototype in
malloc.h).
The docs say memalign will work of the alignment parameter is a multiple of
sizeof( void * ).
sizeof(void *) == 4. AFAIK 4 is a multiple of 4. So the following should
be valid.
#inlcude <malloc.h>
int main()
{
char *buffer = memalign( 4, 512 );
printf( “Buffer: %x\n”, (int) buffer );
printf( “Errno: %d\n”, errno );
}
Yet, buffer is 0 and errno is 22 (EINVAL). So I’m left to assume that it
sizeof( void *) is not considered a multiple of sizeof( void *) or that
memalign() will accept any multiple of sizeof( void *) except sizeof( void
*) itself.
This may be simply a documentation error, but wanted to bring it up in case
this isn’t the expected behavior. I’m using QNX 6.2 SE
Kevin
Just one other note, I tried it using 8 as the alignment parameter and it
worked fine…
Kevin
“Kevin Stallard” <kevin@ffflyingrobots.com> wrote in message
news:af9up2$7bi$1@inn.qnx.com…
I wrote a simple program using memalign().
(BTW the documentation of memalign() doesn’t match the prototype in
malloc.h).
The docs say memalign will work of the alignment parameter is a multiple
of
sizeof( void * ).
sizeof(void *) == 4. AFAIK 4 is a multiple of 4. So the following should
be valid.
#inlcude <malloc.h
int main()
{
char *buffer = memalign( 4, 512 );
printf( “Buffer: %x\n”, (int) buffer );
printf( “Errno: %d\n”, errno );
}
Yet, buffer is 0 and errno is 22 (EINVAL). So I’m left to assume that it
sizeof( void *) is not considered a multiple of sizeof( void *) or that
memalign() will accept any multiple of sizeof( void *) except
izeof( void
*) itself.
This may be simply a documentation error, but wanted to bring it up in
case
this isn’t the expected behavior. I’m using QNX 6.2 SE
Kevin