Mercurial > hg > x
view align8.cpp @ 2:fc19d45615d1
* Make all file names lower-case to avoid case ambiguity
(some includes differed in case from the filenames they were
trying to include). Also replace MinGW-specific mem.h with
string.h
author | Chris Cannam |
---|---|
date | Tue, 05 Oct 2010 11:04:40 +0100 |
parents | 6422640a802f |
children | 92ee28024c05 |
line wrap: on
line source
//--------------------------------------------------------------------------- #include <memory.h> #include <stdlib.h> #include "align8.h" //--------------------------------------------------------------------------- /* function malloc8: 8-byte (64-bit) aligned memory allocation. Returns pointer to a memory block of $size starting at an address divisible by 8. */ void* malloc8(unsigned size) { char *buffer, *result; buffer=(char*)malloc(size+8+sizeof(void*)); if(!buffer) return(NULL); char* tmp=&buffer[sizeof(void*)]; result=&((char*)((unsigned)tmp&0xFFFFFFF8))[8]; ((void**)result)[-1]=buffer; return(result); }//malloc8 /* function free8: deallocation for malloc8() No return value. */ void free8(void* buffer8) { if (buffer8) free(((void**)buffer8)[-1]); }//free8