diff --git a/stralloc/stralloc_0.3 b/stralloc/stralloc_0.3 index 5e83d48..bcd0b0b 100644 --- a/stralloc/stralloc_0.3 +++ b/stralloc/stralloc_0.3 @@ -4,7 +4,7 @@ stralloc_0 \- append \\0 to a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_0\fP(stralloc* \fIsa\fR); +int \fBstralloc_0\fP(stralloc* \fIsa\fR); .SH DESCRIPTION stralloc_0 appends \\0 to a stralloc. diff --git a/stralloc/stralloc_append.3 b/stralloc/stralloc_append.3 index 1bc52a0..5170718 100644 --- a/stralloc/stralloc_append.3 +++ b/stralloc/stralloc_append.3 @@ -4,7 +4,7 @@ stralloc_append \- append a character to a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_append\fP(stralloc* \fIsa\fR,const char* \fIin\fR); +int \fBstralloc_append\fP(stralloc* \fIsa\fR,const char* \fIin\fR); .SH DESCRIPTION stralloc_append appends the byte from *\fIbuf\fR to the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_cat.3 b/stralloc/stralloc_cat.3 index add2caf..332d94d 100644 --- a/stralloc/stralloc_cat.3 +++ b/stralloc/stralloc_cat.3 @@ -4,7 +4,7 @@ stralloc_cat \- append data to a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_cat\fP(stralloc* \fIsato\fR,stralloc* \fIsafrom\fR); +int \fBstralloc_cat\fP(stralloc* \fIsato\fR,stralloc* \fIsafrom\fR); .SH DESCRIPTION stralloc_cat appends the string stored in \fIsafrom\fR to \fIsa\fR. It is the same as diff --git a/stralloc/stralloc_catb.3 b/stralloc/stralloc_catb.3 index e04b9be..8b53f03 100644 --- a/stralloc/stralloc_catb.3 +++ b/stralloc/stralloc_catb.3 @@ -4,7 +4,7 @@ stralloc_catb \- append data to a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned int \fIlen\fR); +int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned int \fIlen\fR); .SH DESCRIPTION stralloc_catb adds the string \fIbuf\fR[0], \fIbuf\fR[1], ... \fIbuf\fR[\fIlen\fR-1] to the end of the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_catlong0.3 b/stralloc/stralloc_catlong0.3 index 5938170..7edd3fc 100644 --- a/stralloc/stralloc_catlong0.3 +++ b/stralloc/stralloc_catlong0.3 @@ -4,7 +4,7 @@ stralloc_catlong0 \- append an integer to a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_catlong0\fP(stralloc* \fIsa\fR, unsigned long \fIin\fR, unsigned int \fIn\fR); +int \fBstralloc_catlong0\fP(stralloc* \fIsa\fR, unsigned long \fIin\fR, unsigned int \fIn\fR); .SH DESCRIPTION stralloc_catlong0 converts in to a string using \fBfmt_long0\fR and appends the result to \fIsa\fR, allocating memory as necessary. diff --git a/stralloc/stralloc_cats.3 b/stralloc/stralloc_cats.3 index fa0a5e2..20fa628 100644 --- a/stralloc/stralloc_cats.3 +++ b/stralloc/stralloc_cats.3 @@ -4,7 +4,7 @@ stralloc_cats \- append data to a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_cats\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR); +int \fBstralloc_cats\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR); .SH DESCRIPTION stralloc_cats appends a \\0-terminated string from \fIbuf\fR to the end of the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_catulong0.3 b/stralloc/stralloc_catulong0.3 index c2a8bd7..f9c89c2 100644 --- a/stralloc/stralloc_catulong0.3 +++ b/stralloc/stralloc_catulong0.3 @@ -4,7 +4,7 @@ stralloc_catulong0 \- append an integer to a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_catulong0\fP(stralloc* \fIsa\fR, unsigned long \fIin\fR, unsigned int \fIn\fR); +int \fBstralloc_catulong0\fP(stralloc* \fIsa\fR, unsigned long \fIin\fR, unsigned int \fIn\fR); .SH DESCRIPTION stralloc_catulong0 converts in to a string using \fBfmt_ulong0\fR and appends the result to \fIsa\fR, allocating memory as necessary. diff --git a/stralloc/stralloc_chomp.3 b/stralloc/stralloc_chomp.3 index 3d06a0e..39508c9 100644 --- a/stralloc/stralloc_chomp.3 +++ b/stralloc/stralloc_chomp.3 @@ -4,7 +4,7 @@ stralloc_chomp \- remove trailing CR, LF or CRLF .SH SYNTAX .B #include -extern int \fBstralloc_chomp\fP(stralloc* \fIsa\fR); +int \fBstralloc_chomp\fP(stralloc* \fIsa\fR); .SH DESCRIPTION stralloc_chomp removes trailing CRLF, CR or LF from \fIsa\fR and returns the number of removed characters (i.e. 0, 1 or 2). diff --git a/stralloc/stralloc_chop.3 b/stralloc/stralloc_chop.3 index 7bf9f3f..7db01fa 100644 --- a/stralloc/stralloc_chop.3 +++ b/stralloc/stralloc_chop.3 @@ -4,7 +4,7 @@ stralloc_chop \- remove and return last char .SH SYNTAX .B #include -extern int \fBstralloc_chop\fP(stralloc* \fIsa\fR); +int \fBstralloc_chop\fP(stralloc* \fIsa\fR); .SH DESCRIPTION stralloc_chop removes the last char in the stralloc (if it is empty, stralloc_chop does nothing and returns -1). This character is cast to diff --git a/stralloc/stralloc_copy.3 b/stralloc/stralloc_copy.3 index 944bf82..002345f 100644 --- a/stralloc/stralloc_copy.3 +++ b/stralloc/stralloc_copy.3 @@ -4,7 +4,7 @@ stralloc_copy \- copy data into a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_copy\fP(stralloc* \fIsato\fR,stralloc* \fIsafrom\fR); +int \fBstralloc_copy\fP(stralloc* \fIsato\fR,stralloc* \fIsafrom\fR); .SH DESCRIPTION stralloc_copy copies the string stored in \fIsafrom\fR into \fIsa\fR. It is the same as diff --git a/stralloc/stralloc_copyb.3 b/stralloc/stralloc_copyb.3 index 551782c..c84bc75 100644 --- a/stralloc/stralloc_copyb.3 +++ b/stralloc/stralloc_copyb.3 @@ -4,7 +4,7 @@ stralloc_copyb \- copy data into a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned int \fIlen\fR); +int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned int \fIlen\fR); .SH DESCRIPTION stralloc_copyb makes sure that \fIsa\fR has enough space allocated to hold \fIlen\fR bytes. Then it copies the first \fIlen\fR bytes from diff --git a/stralloc/stralloc_copys.3 b/stralloc/stralloc_copys.3 index 2181f95..6570c27 100644 --- a/stralloc/stralloc_copys.3 +++ b/stralloc/stralloc_copys.3 @@ -4,7 +4,7 @@ stralloc_copys \- copy data into a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_copys\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR); +int \fBstralloc_copys\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR); .SH DESCRIPTION stralloc_copys copies a \\0-terminated string from \fIbuf\fR into \fIsa\fR, without the \\0. It is the same as diff --git a/stralloc/stralloc_free.3 b/stralloc/stralloc_free.3 index c10a2e3..2ef6e37 100644 --- a/stralloc/stralloc_free.3 +++ b/stralloc/stralloc_free.3 @@ -4,7 +4,7 @@ stralloc_free \- free storage associated with a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_free\fP(stralloc* \fIsa\fR); +int \fBstralloc_free\fP(stralloc* \fIsa\fR); .SH DESCRIPTION stralloc_free returns the storage associated with \fIsa\fR to the system. Afterwards, the stralloc is unallocated. diff --git a/stralloc/stralloc_init.3 b/stralloc/stralloc_init.3 new file mode 100644 index 0000000..fc4430c --- /dev/null +++ b/stralloc/stralloc_init.3 @@ -0,0 +1,15 @@ +.TH stralloc_init 3 +.SH NAME +stralloc_init \- initialize a stralloc +.SH SYNTAX +.B #include + +int \fBstralloc_init\fP(stralloc* \fIsa\fR); +.SH DESCRIPTION +stralloc_init initializes a stralloc to the empty string. + +It does not free any memory previously associated with a stralloc. Use +stralloc_free(3) for that. If you just want to empty a stralloc, use +stralloc_copys(sa,"") instead. +.SH "SEE ALSO" +stralloc_free(3), stralloc_copys(3) diff --git a/stralloc/stralloc_init.c b/stralloc/stralloc_init.c new file mode 100644 index 0000000..9502070 --- /dev/null +++ b/stralloc/stralloc_init.c @@ -0,0 +1,6 @@ +#include "stralloc.h" + +void stralloc_init(stralloc* sa) { + sa->s=0; + sa->len=sa->a=0; +} diff --git a/stralloc/stralloc_ready.3 b/stralloc/stralloc_ready.3 index 8e33b0d..eac9a8d 100644 --- a/stralloc/stralloc_ready.3 +++ b/stralloc/stralloc_ready.3 @@ -4,7 +4,7 @@ stralloc_ready \- provide space in a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_ready\fP(stralloc* \fIsa\fR,unsigned int \fIlen\fR); +int \fBstralloc_ready\fP(stralloc* \fIsa\fR,unsigned int \fIlen\fR); .SH DESCRIPTION stralloc_ready makes sure that \fIsa\fR has enough space allocated to hold \fIlen\fR bytes: If \fIsa\fR is not allocated, stralloc_ready allocates at least diff --git a/stralloc/stralloc_readyplus.3 b/stralloc/stralloc_readyplus.3 index 70437ba..c233deb 100644 --- a/stralloc/stralloc_readyplus.3 +++ b/stralloc/stralloc_readyplus.3 @@ -4,7 +4,7 @@ stralloc_readyplus \- provide space in a stralloc .SH SYNTAX .B #include -extern int \fBstralloc_readyplus\fP(stralloc* \fIsa\fR,unsigned int \fIlen\fR); +int \fBstralloc_readyplus\fP(stralloc* \fIsa\fR,unsigned int \fIlen\fR); .SH DESCRIPTION stralloc_readyplus makes sure that \fIsa\fR has enough space allocated to hold an additional \fIlen\fR bytes: If \fIsa\fR is not allocated, diff --git a/stralloc/stralloc_starts.3 b/stralloc/stralloc_starts.3 index 5c49623..c05e643 100644 --- a/stralloc/stralloc_starts.3 +++ b/stralloc/stralloc_starts.3 @@ -4,7 +4,7 @@ stralloc_starts \- check if string is prefix of stralloc .SH SYNTAX .B #include -extern int \fBstralloc_starts\fP(stralloc* \fIsa\fR,const char* \fIin\fR); +int \fBstralloc_starts\fP(stralloc* \fIsa\fR,const char* \fIin\fR); .SH DESCRIPTION stralloc_starts returns 1 if the \\0-terminated string in \fIbuf\fR, without the terminating \\0, is a prefix of the string stored in \fIsa\fR. Otherwise