P-p-H-d / mlib

Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
BSD 2-Clause "Simplified" License
869 stars 76 forks source link

How to define REALLOC in OPLIST? #111

Closed lindsaywhitney closed 1 year ago

lindsaywhitney commented 1 year ago

How to define REALLOC in OPLIST? There is error in following code:

static data_node data_node_realloc(data_node obj, size_t size);

ARRAY_DEF(/ the array prefix / array_data_node, / the object type / data_node, / the object oplist / (INIT(API_2(data_node_init)), SET(API_6(data_node_set)), REALLOC(API(data_node_realloc,ARGPTR1,ARGPTR2,ARG3)), INIT_SET(API_6(data_node_init_set)), CLEAR(API_2(data_node_clear))))

P-p-H-d commented 1 year ago

Hi,

You need to define it like this:

ARRAY_DEF(/* the array prefix */ array_data_node,
      /* the object type */ data_node,
      /* the object oplist */ (INIT(API_2(data_node_init)),
                   SET(API_6(data_node_set)),
                   REALLOC(API(data_node_realloc,NONE, ARG2, ARG3)),
                   INIT_SET(API_6(data_node_init_set)),
                   CLEAR(API_2(data_node_clear))))

More information:

Additional notes on this code which may be bugs: