https://github.com/skullchap/buf
ANSI C89 dynamic buffer lib + code generator macros to help build custom vectors/dynamic array like wrappers and etc.
https://github.com/skullchap/buf
array buffer c c89 dynamic-array dynamic-buffer vector
Last synced: 4 months ago
JSON representation
ANSI C89 dynamic buffer lib + code generator macros to help build custom vectors/dynamic array like wrappers and etc.
- Host: GitHub
- URL: https://github.com/skullchap/buf
- Owner: skullchap
- License: other
- Created: 2024-06-03T02:26:35.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-13T13:12:18.000Z (9 months ago)
- Last Synced: 2024-09-30T01:21:28.477Z (9 months ago)
- Topics: array, buffer, c, c89, dynamic-array, dynamic-buffer, vector
- Language: C
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.txt
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
ANSI C89 compatible, dynamic buffer lib.
Buf* newbuf(long cap);
void freebuf(Buf*);
long buflen(Buf*);
void setbuflen(Buf*, long len);
long bufcap(Buf*);
int setbufcap(Buf*, long cap);
void* bufmem(Buf*);
void* bufcursor(Buf*);
void* bufoff(Buf*, long off);
Buf* copybuf(Buf*);
int appendbuf(Buf*, void*, long);
int insertbuf(Buf*, long off, void*, long);
Buf* slicebuf(Buf*, long from, long till);
int cutbuf(Buf *b, long from, long till);
int fillbuf(Buf*, int c, long from, long till);Functions return either NULL or negative number on error.
appendbuf and insertbuf can set errno to ERANGE on long add overflow condition.
slicebuf, cutbuf and fillbuf can set errno to ERANGE on from >= till condition.example/veci.c contains how type vector wrappers could be made.
vecdef.h is a set of code generator macros to help build type vector wrappers
similar to ones found in example/veci.c. It has vecprotos and vecfuncs macros,
that generate vector prototypes and functions for a given type.
example/vecgen contains how vecdef.h could be used.