chickadee » jiffi » define-array-allocators

(define-array-allocators ...)syntax

Defines various procedures to manage memory for an armor type that will hold a C array of structs or unions. You can omit any procedures that you don't need. Also generates type declarations for the procedures that are defined.

See "Which allocator should I use?" in the Getting Started guide.


  free:       FREE                 ; optional
  alloc:      ALLOC                ; optional
  alloc/blob: ALLOC/BLOB           ; optional
  make:       MAKE                 ; optional
  make/af:    MAKE/AUTOFREE        ; optional
  make/blob:  MAKE/BLOB            ; optional
  defaults:   (SLOT-DEFAULT ...)   ; optional

This is very similar to define-struct-allocators, except that the "alloc" and "make" procedures take a length argument for the number of items in the array.

"STRUCT_NAME" is a string containing the name of the C struct/union (not the array type), exactly as it appears in C. For example, for an array of FOO_Event structs, just write "FOO_Event".

FREE will be defined as an array freer, ALLOC and ALLOC/BLOB will be defined as array memory allocators, and MAKE, MAKE/AUTOFREE, and MAKE/BLOB will be defined as array makers.

The SLOT-DEFAULTs are the defaults for the slots after the first. They should not include a default for first slot, which is recommended to hold the array length. The "make" procedures will call (WRAP data length SLOT-DEFAULT ...).


  (event "FOO_Event" event? wrap-event)
  free:       free-event!
  alloc:      alloc-event
  alloc/blob: alloc-event/blob
  make:       make-event
  make/af:    make-event/autofree
  make/blob:  make-event/blob
  defaults:   ("e1" 'e2))     ; defaults for `extra1' and `extra2'