Commit 3ecf92fc authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Remove the custom memory pool

parent 983824b9
......@@ -34,7 +34,6 @@ include %reldir%/handfuls/Makefile.am
include %reldir%/hands/Makefile.am
include %reldir%/trick/Makefile.am
include %reldir%/tricks/Makefile.am
include %reldir%/pool/Makefile.am
include %reldir%/test/Makefile.am
include %reldir%/pkgconfig/Makefile.am
include %reldir%/cards/Makefile.am
......
# tarot implements the rules of the tarot game
# Copyright (C) 2018, 2019 Vivien Kraus
# 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, version 3 of the License.
#
# 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, see <http://www.gnu.org/licenses/>.
AM_CPPFLAGS += -I $(srcdir)/%reldir% -I %reldir%
src_libtarot_libtarot_la_SOURCES += \
%reldir%/pool.h
/* tarot implements the rules of the tarot game
* Copyright (C) 2019 Vivien Kraus
*
* 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, version 3 of the License.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef H_TAROT_POOL_INCLUDED
#define H_TAROT_POOL_INCLUDED
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
static inline int
align_head (size_t *available, char **head, size_t alignment)
{
size_t offset = (size_t) *head;
size_t padding = (alignment - (offset % alignment)) % alignment;
if (*available < padding)
{
return 1;
}
*available -= padding;
*head += padding;
return 0;
}
static inline void *talloc (size_t *available, char **head, size_t sz,
size_t alignment)
{
int align_error = align_head (available, head, alignment);
void *ret = NULL;
if (align_error)
{
return NULL;
}
if (*available < sz)
{
return NULL;
}
ret = *head;
*available -= sz;
*head += sz;
return ret;
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* H_TAROT_POOL_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment