Commit 7325f59c authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Do not export the counter construction without memory allocation

parent dd23c85a
......@@ -1389,22 +1389,6 @@ functions.
Return the data associated to the current position of /iterator/, and
advance /iterator/ to the next position.
#+attr_texinfo: :options {size_t} tarot_counter_construct (size_t @var{maxmem}, char *@var{memout}, size_t *@var{alignment})
If you want to control how memory is allocated, because you have a
very good specific memory allocator you want to use, then you will not
be satisfied by the =tarot_*_alloc= / =tarot_*_dup= family of
functions. This function constructs in place a new object in /mem/
(only used if /maxmem/ is sufficiently large), and return the actual
number of bytes that are needed to hold the game state. The return
value is never 0.
If /maxmem/ is sufficiently large, then /mem/ should be aligned to the
value set in /alignment/ from the previous call. In most cases you
should not worry, since the alignment is never stricter than the
maximum alignment of =max_align_t=.
** XML representation of games
#+index: relax-ng
The XML representation of a game is simply the collection of events
......@@ -22,23 +22,12 @@
#include <assert.h>
#include "xalloc.h"
#ifdef __FRAMAC__
#undef alignof
#define alignof(x) (16)
#endif /* __FRAMAC__ */
TarotCounter *
tarot_counter_alloc (void)
size_t alignment;
size_t required = tarot_counter_construct (0, NULL, &alignment);
size_t unused;
void *mem = xmalloc (required);
assert (alignment >= 1 && alignment <= alignof (max_align_t));
unused = tarot_counter_construct (required, mem, &alignment);
assert (unused == required);
(void) unused;
return mem;
TarotCounter *ret = xmalloc (sizeof (TarotCounter));
counter_initialize (ret);
return ret;
TarotCounter *
......@@ -55,18 +44,6 @@ tarot_counter_free (TarotCounter * counter)
free (counter);
tarot_counter_construct (size_t max_mem, char *mem, size_t *alignment)
*alignment = alignof (TarotCounter);
if (max_mem >= sizeof (TarotCounter))
assert (((size_t) mem) % (*alignment) == 0);
counter_initialize ((TarotCounter *) mem);
return sizeof (TarotCounter);
tarot_counter_copy (TarotCounter * dest, const TarotCounter * source)
......@@ -30,14 +30,6 @@ extern "C"
struct TarotCounter;
typedef struct TarotCounter TarotCounter;
* tarot_counter_construct:
* @mem_out: (array length=max_mem):
* @alignment: (out):
size_t tarot_counter_construct (size_t max_mem, char *mem_out,
size_t *alignment);
* tarot_counter_alloc: (constructor)
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