From f855e24b563c96ea12c8184903c3524a7efd8911 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 11 Jul 2019 12:29:00 +0200 Subject: [PATCH] Add description of operator INC_ALLOC --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ef417a38..70359dbd 100644 --- a/README.md +++ b/README.md @@ -492,6 +492,7 @@ Other documented operators are: * DEL (&obj): free the allocated uninitialized object 'obj' (default is M\_MEMORY\_DEL). The object is not cleared before being free (CLEAR operator has to be called before). The object shall have been allocated by the NEW operator. * REALLOC(type, type pointer, number) --> type pointer: realloc the given type pointer (either NULL or a pointer returned by the REALLOC operator itself) to an array of number objects of this type. Previously objects pointed by the pointer are kept up to the minimum of the new or old array size. New objects are not initialized (INIT operator has to be called afterward). Freed objects are not cleared (CLEAR operator has to be called before). The default is M\_MEMORY\_REALLOC. * FREE (&obj) : free the allocated uninitialized array object 'obj' (default is M\_MEMORY\_FREE). The objects are not cleared before being free (CLEAR operator has to be called before). The object shall have been allocated by the REALLOC operator. +* INC\_ALLOC(size\_t s) -> size\_t: Define the growing policy of an array (or equivalent structure). It shall return the new allocation size based on the old allocation size ('s'). Default policy is to get the max between '2*s' and 16. * INIT\_MOVE(objd, objc): Initialize 'objd' to the same state than 'objc' by stealing as resources as possible from 'objc', and then clear 'objc'. It is semantically equivalent to calling INIT\_SET(objd,objc) then CLEAR(objc) (but usually way faster). By default, all objects are assumed to be **trivially movable** (i.e. using memcpy to move an object is safe). Most C objects are trivially movable. If an object is not trivially movable, it shall provide an INIT\_MOVE method or disable the INIT\_MOVE method entirely. * MOVE(objd, objc): Set 'objd' to the same state than 'objc' by stealing as resources as possible from 'objc' and then clear 'objc'. It is equivalent to calling SET(objd,objc) then CLEAR(objc) or CLEAR(objd) and then INIT\_MOVE(objd, objc). TBC if operator is really needed as calling CLEAR then INIT\_MOVE is what does all known implementation. * INIT\_WITH(obj,...): Initialize the object 'obj' with a variable arguments. Arguments can be of different types. This is used within the M\_LET macro to initialize objects with values.