logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

soldout_buffer, bufcasecmp, bufcmp, bufcmps, bufdup, bufgrow, bufnew, bufnullterm, bufprintf, bufput,

Authors

       The soldout library was written by Natasha "Kerensikova" Porte <natacha@instinctive.eu>.  Manual page was
       originally written by Massimo Manghi <mxmanghi@apache.org>, and rewritten to mdoc  format  by  Svyatoslav
       Mishyn <juef@openmailbox.org>.

Debian                                           April 13, 2016                                SOLDOUT_BUFFER(3)

Description

Variables
       Compile time options.  Statistics are kept about memory usage.

       buffer_stat_nb
       show how many buffers were created.

       buffer_stat_alloc_bytes
       show how many bytes were allocated.

   Typesstructbuf
       character array buffer.  Consists of the following fields:

       char*data
               actual character data.

       size_tsize
               size of the string.

       size_tasize
               allocated size (0 = volatile buffer).

       size_tunit
               reallocation unit size (0 = read-only buffer).

       intref
               reference count.

   Macros
       CONST_BUF
       create a global buffer name from a string literal string.

       VOLATILE_BUF
       create a volatile buffer name on the stack from a string strname.

       BUFPUTSL
       optimized bufputs() of a string literal.

   Functionsbufcasecmp()
       compare two buffers ignoring case.

       bufcmp()
       compare two buffers.

       bufcmps()
       compare a buffer to a string.

       bufdup()
       duplicate a buffer src.

       bufgrow()
       increase the allocated size to the given value.

       bufnew()
       create a new buffer.

       bufnullterm()
       terminate the string array by NUL (making a C-string).

       bufprintf()
       print formatted output to a buffer buf.

       bufput()
       append raw data to a buffer buf.

       bufputs()
       append a NUL-terminated string str to a buffer buf.

       bufputc()
       append a single char c to a buffer buf.

       bufrelease()
       decrease the reference count and free the buffer buf if needed.

       bufreset()
       free internal data of the buffer buf.

       bufset()
       safely assign a buffer to another.

       bufslurp()
       remove a given number of bytes from the head of the array.

       buftoi()
       convert the numbers at the beginning of the buffer buf into an int.

       vbufprintf()
       stdarg(3) variant of formatted printing into a buffer buf.

Name

       soldout_buffer,  bufcasecmp,  bufcmp,  bufcmps,  bufdup, bufgrow, bufnew, bufnullterm, bufprintf, bufput,
       bufputs, bufputc, bufrelease, bufreset, bufset, bufslurp, buftoi, vbufprintf — buffer handling  functions
       for soldout

Return Values

       The bufcasecmp(), bufcmp() and bufcmps() functions return an integer less than, equal to, or greater than
       zero if a is found, respectively, to be less than, to match, or be greater than b.

       The bufdup() and bufnew() functions return a structbuf* on success; on error they return NULL.

       The bufgrow() function returns on success 1; on error - 0.

       The  bufnullterm(),  bufprintf(),  bufput(),  bufputs(),  bufputc(),  bufrelease(), bufreset(), bufset(),
       bufslurp() and vbufprintf() functions do not return a value.

       The buftoi() function return the converted value.

See Also

soldout(3), stdarg(3)

Synopsis

#include<buffer.h>#defineCONST_BUF(name,string)#defineVOLATILE_BUF(name,strname)#defineBUFPUTSL(output,literal)intbufcasecmp(conststructbuf*a, conststructbuf*b);

       intbufcmp(conststructbuf*a, conststructbuf*b);

       intbufcmps(conststructbuf*a, constchar*b);

       structbuf*bufdup(conststructbuf*src, size_tdupunit);

       intbufgrow(structbuf*buf, size_tsz);

       structbuf*bufnew(size_tunit);

       voidbufnullterm(structbuf*buf);

       voidbufprintf(structbuf*buf, constchar*fmt, ...);

       voidbufput(structbuf*buf, constvoid*data, size_tlen);

       voidbufputs(structbuf*buf, constchar*str);

       voidbufputc(structbuf*buf, charc);

       voidbufrelease(structbuf*buf);

       voidbufreset(structbuf*buf);

       voidbufset(structbuf**dest, structbuf*src);

       voidbufslurp(structbuf*buf, size_tlen);

       intbuftoi(structbuf*buf, size_toffset_i, size_t*offset_o);

       voidvbufprintf(structbuf*buf, constchar*fmt, va_listap);

       externlongbuffer_stat_nb;externsize_tbuffer_stat_alloc_bytes;

See Also