00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include <stdlib.h>
00021 
00022 #if defined(__MINGW32__)
00023 #if __GNUC__ < 4
00024   #include <malloc.h>
00025   #define FLGR_ALIGNED_MALLOC(ptr,size, align)  ptr = __mingw_aligned_malloc(size,align)
00026   #define FLGR_ALIGNED_FREE(p)                  __mingw_aligned_free(p)
00027 #else
00028   #include <mm_malloc.h>
00029   #define FLGR_ALIGNED_MALLOC(ptr,size,align)   ptr = _mm_malloc(size,align)
00030   #define FLGR_ALIGNED_FREE(p)                  _mm_free(p)
00031 #endif
00032 #elif __GNUC__ < 4
00033   #define FLGR_ALIGNED_MALLOC(ptr,size, align)  posix_memalign (&ptr, alignment, size)
00034   #define FLGR_ALIGNED_FREE(p)                  free (ptr);
00035 #else
00036   #include <mm_malloc.h>
00037   #define FLGR_ALIGNED_MALLOC(ptr,size,align)   ptr = _mm_malloc(size,align)
00038   #define FLGR_ALIGNED_FREE(p)                  _mm_free(p)
00039 #endif
00040 
00041 #include "flgrCoreErrors.h"
00042 #include "flgrCoreMalloc.h"
00043 #include "flgrCoreDispatch.h"
00044 
00045 
00051 
00052 
00056 
00057 void *flgr_malloc(size_t size) {
00058   void *tmp = malloc(size);
00059 
00060   
00061 
00062   if(tmp==NULL) {
00063     POST_ERROR("Could not allocate data, returning NULL pointer !\n");
00064     return NULL;
00065   }
00066 
00067   return tmp;
00068 }
00069 
00070 
00072 
00077 
00078 void *flgr_malloc_align(size_t size, size_t alignment) {
00079   void *tmp;
00080 
00081   
00082 
00083   FLGR_ALIGNED_MALLOC(tmp,size,alignment);
00084 
00085   if(tmp==NULL) {
00086     POST_ERROR("Could not allocate data, returning NULL pointer !\n");
00087     return NULL;
00088   }
00089 
00090   return tmp;
00091 
00092 }
00093 
00095 
00099 
00100 void flgr_free(void *ptr) {
00101   
00102 
00103   free(ptr);
00104 }
00105 
00106 
00108 
00112 
00113 void flgr_free_align(void *ptr) {
00114   
00115 
00116   FLGR_ALIGNED_FREE(ptr);
00117 }
00118