--- /dev/null
+#include "ol_malloc.h"
+
+#ifdef OL_MALLOC_WINDOWS
+void *ol_aligned_malloc(size_t size, size_t alignment)
+{
+ return _aligned_malloc(size, alignment);
+}
+
+void ol_aligned_free(void *mem)
+{
+ return _aligned_free(mem);
+}
+#else
+void *ol_aligned_malloc(size_t size, size_t alignment)
+{
+ return memalign(alignment, size);
+}
+
+void ol_aligned_free(void *mem)
+{
+ return free(mem);
+}
+#endif
\ No newline at end of file
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <malloc.h>
+#include "ol_malloc.h"
#include "trace.h"
ctx->btbuf = NULL;
ctx->sibuf = NULL;
} else {
- ctx->k = memalign(64, 16 * ctx->ksize);
+ ctx->k = ol_aligned_malloc(16 * ctx->ksize, 64);
ctx->kpad = ctx->ksize / 2;
- ctx->bibuf = memalign(64, ctx->aw * (ctx->ah + 2 * ctx->kpad));
- ctx->btbuf = memalign(64, ctx->ah * (ctx->aw + 2 * ctx->kpad));
- ctx->sibuf = memalign(64, ctx->aw * (ctx->ah + 2));
+ ctx->bibuf = ol_aligned_malloc(ctx->aw * (ctx->ah + 2 * ctx->kpad), 64);
+ ctx->btbuf = ol_aligned_malloc(ctx->ah * (ctx->aw + 2 * ctx->kpad), 64);
+ ctx->sibuf = ol_aligned_malloc(ctx->aw * (ctx->ah + 2), 64);
}
if (ctx->p.mode == OL_TRACE_CANNY) {
if (!ctx->sibuf)
- ctx->sibuf = memalign(64, ctx->aw * (ctx->ah + 2));
- ctx->stbuf = memalign(64, sizeof(*ctx->stbuf) * ctx->ah * (ctx->aw + 2));
- ctx->sxbuf = memalign(64, sizeof(*ctx->sxbuf) * ctx->aw * ctx->ah);
- ctx->sybuf = memalign(64, sizeof(*ctx->sybuf) * ctx->aw * ctx->ah);
- ctx->smbuf = memalign(64, sizeof(*ctx->smbuf) * ctx->aw * ctx->ah);
+ ctx->sibuf = ol_aligned_malloc(ctx->aw * (ctx->ah + 2), 64);
+ ctx->stbuf = ol_aligned_malloc(sizeof(*ctx->stbuf) * ctx->ah * (ctx->aw + 2), 64);
+ ctx->sxbuf = ol_aligned_malloc(sizeof(*ctx->sxbuf) * ctx->aw * ctx->ah, 64);
+ ctx->sybuf = ol_aligned_malloc(sizeof(*ctx->sybuf) * ctx->aw * ctx->ah, 64);
+ ctx->smbuf = ol_aligned_malloc(sizeof(*ctx->smbuf) * ctx->aw * ctx->ah, 64);
} else {
ctx->stbuf = NULL;
ctx->sxbuf = NULL;
if (ctx->pb)
free(ctx->pb);
if (ctx->k)
- free(ctx->k);
+ ol_aligned_free(ctx->k);
if (ctx->bibuf)
- free(ctx->bibuf);
+ ol_aligned_free(ctx->bibuf);
if (ctx->btbuf)
- free(ctx->btbuf);
+ ol_aligned_free(ctx->btbuf);
if (ctx->sibuf)
- free(ctx->sibuf);
+ ol_aligned_free(ctx->sibuf);
if (ctx->stbuf)
- free(ctx->stbuf);
+ ol_aligned_free(ctx->stbuf);
if (ctx->sxbuf)
- free(ctx->sxbuf);
+ ol_aligned_free(ctx->sxbuf);
if (ctx->sybuf)
- free(ctx->sybuf);
+ ol_aligned_free(ctx->sybuf);
if (ctx->smbuf)
- free(ctx->smbuf);
+ ol_aligned_free(ctx->smbuf);
}
static void init_blur(OLTraceCtx *ctx)