2012-04-30 14:24:11 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
2018-06-01 18:19:39 +02:00
|
|
|
*/
|
2011-02-18 13:58:08 +00:00
|
|
|
|
2019-02-06 15:42:22 +11:00
|
|
|
/** \file \ingroup bli
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLI_MEMARENA_H__
|
|
|
|
#define __BLI_MEMARENA_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-07-12 18:04:10 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
#include "BLI_compiler_attrs.h"
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/* A reasonable standard buffer size, big
|
|
|
|
* enough to not cause much internal fragmentation,
|
|
|
|
* small enough not to waste resources
|
|
|
|
*/
|
2013-10-10 18:18:13 +00:00
|
|
|
#define BLI_MEMARENA_STD_BUFSIZE MEM_SIZE_OPTIMAL(1 << 14)
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
struct MemArena;
|
|
|
|
typedef struct MemArena MemArena;
|
|
|
|
|
2013-12-02 17:46:19 +11:00
|
|
|
struct MemArena *BLI_memarena_new(const size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2) ATTR_MALLOC;
|
2013-09-01 15:01:15 +00:00
|
|
|
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1);
|
|
|
|
void BLI_memarena_use_malloc(struct MemArena *ma) ATTR_NONNULL(1);
|
|
|
|
void BLI_memarena_use_calloc(struct MemArena *ma) ATTR_NONNULL(1);
|
2013-12-02 17:46:19 +11:00
|
|
|
void BLI_memarena_use_align(struct MemArena *ma, const size_t align) ATTR_NONNULL(1);
|
|
|
|
void *BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2);
|
|
|
|
void *BLI_memarena_calloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-09-01 22:47:44 +00:00
|
|
|
void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1);
|
2009-07-12 18:04:10 +00:00
|
|
|
|
2013-08-20 16:56:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
2002-10-30 02:07:20 +00:00
|
|
|
|
2013-08-20 16:56:46 +00:00
|
|
|
#endif /* __BLI_MEMARENA_H__ */
|