Skip to content
/ buf Public

ANSI C89 dynamic buffer lib + code generator macros to help build custom vectors/dynamic array like wrappers and etc.

License

Notifications You must be signed in to change notification settings

skullchap/buf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

ANSI C89 dynamic buffer lib + code generator macros to help build custom vectors/dynamic array like wrappers and etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages