diff options
| author | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-26 16:38:00 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-26 16:38:00 -0400 |
| commit | 97d5c458cfa039d857301e1ca7d5af3beb37131d (patch) | |
| tree | b460cd850d0537eb71806ba30358840377b27688 /static/plan9-4e/man2/bin.2 | |
| parent | b89dc2331a50c63f8b33272a5c4c61ab98abdaa3 (diff) | |
build: Better Build System
Diffstat (limited to 'static/plan9-4e/man2/bin.2')
| -rw-r--r-- | static/plan9-4e/man2/bin.2 | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/static/plan9-4e/man2/bin.2 b/static/plan9-4e/man2/bin.2 new file mode 100644 index 00000000..f711b21d --- /dev/null +++ b/static/plan9-4e/man2/bin.2 @@ -0,0 +1,99 @@ +.TH BIN 2 +.SH NAME +binalloc, bingrow, binfree \- grouped memory allocation +.SH SYNOPSIS +.B #include <u.h> +.br +.B #include <libc.h> +.br +.B #include <bin.h> +.PP +.ta \w'\fLvoid* 'u +.PP +.B +typedef struct Bin Bin; +.PP +.B +void *binalloc(Bin **bp, ulong size, int clr); +.PP +.B +void *bingrow(Bin **bp, void *op, ulong osize, +.br +.B + ulong size, int clr); +.PP +.B +void binfree(Bin **bp); +.SH DESCRIPTION +These routines provide simple grouped memory allocation and deallocation. +Items allocated with +.I binalloc +are added to the +.I Bin +pointed to by +.IR bp . +All items in a bin may be freed with one call to +.IR binfree ; +there is no way to free a single item. +.PP +.I Binalloc +returns a pointer to a new block of at least +.I size +bytes. +The block is suitably aligned for storage of any type of object. +No two active pointers from +.I binalloc +will have the same value. +The call +.B binalloc(0) +returns a valid pointer rather than null. +If +.I clr +is non-zero, the allocated memory is set to 0; +otherwise, the contents are undefined. +.PP +.I Bingrow +is used to extend the size of a block of memory returned by +.IR binalloc . +.I Bp +must point to the same bin group used to allocate the original block, +and +.I osize +must be the last size used to allocate or grow the block. +A pointer to a block of at least +.I size +bytes is returned, with the same contents in the first +.I osize +locations. +If +.I clr +is non-zero, the remaining bytes are set to 0, +and are undefined otherwise. +If +.I op +is +.BR nil , +it and +.I osize +are ignored, and the result is the same as calling +.IR binalloc . +.PP +.I Binalloc +and +.I bingrow +allocate large chunks of memory using +.IR malloc (2) +and return pieces of these chunks. +The chunks are +.IR free 'd +upon a call to +.IR binfree . +.SH SOURCE +.B /sys/src/libbin +.SH SEE ALSO +.IR malloc (2) +.SH DIAGNOSTICS +.I binalloc +and +.I bingrow +return 0 if there is no available memory. |
