18a1362adSmaya/**************************************************************************
28a1362adSmaya *
38a1362adSmaya * Copyright 2008-2010 VMware, Inc.
48a1362adSmaya * All Rights Reserved.
58a1362adSmaya *
68a1362adSmaya * Permission is hereby granted, free of charge, to any person obtaining a
78a1362adSmaya * copy of this software and associated documentation files (the
88a1362adSmaya * "Software"), to deal in the Software without restriction, including
98a1362adSmaya * without limitation the rights to use, copy, modify, merge, publish,
108a1362adSmaya * distribute, sub license, and/or sell copies of the Software, and to
118a1362adSmaya * permit persons to whom the Software is furnished to do so, subject to
128a1362adSmaya * the following conditions:
138a1362adSmaya *
148a1362adSmaya * The above copyright notice and this permission notice (including the
158a1362adSmaya * next paragraph) shall be included in all copies or substantial portions
168a1362adSmaya * of the Software.
178a1362adSmaya *
188a1362adSmaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
198a1362adSmaya * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
208a1362adSmaya * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
218a1362adSmaya * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
228a1362adSmaya * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
238a1362adSmaya * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
248a1362adSmaya * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
258a1362adSmaya *
268a1362adSmaya **************************************************************************/
278a1362adSmaya
288a1362adSmaya
298a1362adSmaya/*
308a1362adSmaya * OS memory management abstractions for the standard C library.
318a1362adSmaya */
328a1362adSmaya
338a1362adSmaya
348a1362adSmaya#ifndef _OS_MEMORY_H_
358a1362adSmaya#error "Must not be included directly. Include os_memory.h instead"
368a1362adSmaya#endif
378a1362adSmaya
388a1362adSmaya#include <stdlib.h>
398a1362adSmaya
408a1362adSmaya
418a1362adSmaya#define os_malloc(_size)  malloc(_size)
428a1362adSmaya#define os_calloc(_count, _size )  calloc(_count, _size )
438a1362adSmaya#define os_free(_ptr)  free(_ptr)
448a1362adSmaya
458a1362adSmaya#define os_realloc( _old_ptr, _old_size, _new_size) \
468a1362adSmaya   realloc(_old_ptr, _new_size + 0*(_old_size))
478a1362adSmaya
487ec681f3Smrg#if DETECT_OS_WINDOWS
498a1362adSmaya
508a1362adSmaya#include <malloc.h>
518a1362adSmaya
528a1362adSmaya#define os_malloc_aligned(_size, _align) _aligned_malloc(_size, _align)
538a1362adSmaya#define os_free_aligned(_ptr) _aligned_free(_ptr)
547ec681f3Smrg#define os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment) _aligned_realloc(_ptr, _newsize, _alignment)
558a1362adSmaya
568a1362adSmaya#else
578a1362adSmaya
588a1362adSmaya#include "os_memory_aligned.h"
598a1362adSmaya
607ec681f3Smrg#if DETECT_OS_UNIX
617ec681f3Smrg
627ec681f3Smrg#include "os_memory_fd.h"
637ec681f3Smrg
647ec681f3Smrg#endif
657ec681f3Smrg
668a1362adSmaya#endif
67