*
* JasPer License Version 2.0
*
+ * Copyright (c) 2001-2006 Michael David Adams
* Copyright (c) 1999-2000 Image Power, Inc.
* Copyright (c) 1999-2000 The University of British Columbia
- * Copyright (c) 2001-2003 Michael David Adams
*
* All rights reserved.
*
/*
* Memory Allocator
*
- * $Id: jas_malloc.c,v 1.1 2007/01/15 16:09:24 vp153 Exp $
+ * $Id: jas_malloc.c,v 1.2 2008/05/26 09:40:52 vp153 Exp $
*/
/******************************************************************************\
\******************************************************************************/
#include <stdio.h>
+#include <stdlib.h>
/* We need the prototype for memset. */
#include <string.h>
#if !defined(DEBUG_MEMALLOC)
+#define MEMALLOC_ALIGNMENT 32
+#define MEMALLOC_ALIGN2
+#undef MEMALLOC_ALIGN2
+
void *jas_malloc(size_t size)
{
+#if defined(MEMALLOC_ALIGN2)
+ void *ptr;
+abort();
+ if (posix_memalign(&ptr, MEMALLOC_ALIGNMENT, size)) {
+ return 0;
+ }
+ return ptr;
+#endif
return malloc(size);
}