diff --git a/CHANGES b/CHANGES index 289ed32..d0f0b54 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ TCP_CORK (saves two syscalls) add io_fd_flags so the caller can tell io_fd whether the socket is blocking (saves one fcntl syscall) + more constness for stralloc and buffer 0.29: save 8 bytes in taia.h for 64-bit systems diff --git a/buffer.h b/buffer.h index 935b9bf..3fff05d 100644 --- a/buffer.h +++ b/buffer.h @@ -107,9 +107,9 @@ extern buffer *buffer_2; #ifdef STRALLOC_H /* write stralloc to buffer */ -int buffer_putsa(buffer* b,stralloc* sa); +int buffer_putsa(buffer* b,const stralloc* sa); /* write stralloc to buffer and flush */ -int buffer_putsaflush(buffer* b,stralloc* sa); +int buffer_putsaflush(buffer* b,const stralloc* sa); /* these "read token" functions return 0 if the token was complete or * EOF was hit or -1 on error. In contrast to the non-stralloc token @@ -141,7 +141,7 @@ int buffer_get_new_token_sa_pred(buffer* b,stralloc* sa,sa_predicate p); /* make a buffer from a stralloc. * Do not change the stralloc after this! */ -void buffer_fromsa(buffer* b,stralloc* sa); /* read from sa */ +void buffer_fromsa(buffer* b,const stralloc* sa); /* read from sa */ int buffer_tosa(buffer*b,stralloc* sa); /* write to sa, auto-growing it */ #endif diff --git a/buffer/buffer_fromsa.3 b/buffer/buffer_fromsa.3 index a236190..962239d 100644 --- a/buffer/buffer_fromsa.3 +++ b/buffer/buffer_fromsa.3 @@ -4,7 +4,7 @@ buffer_fromsa \- initialize buffer structure from stralloc .SH SYNTAX .B #include -void \fBbuffer_fromsa\fR(buffer* \fIb\fR,stralloc* \fIsa\fR); +void \fBbuffer_fromsa\fR(buffer* \fIb\fR,const stralloc* \fIsa\fR); .SH DESCRIPTION buffer_fromsa makes a virtual read buffer from a stralloc. The buffer reading functions will be able to read until the end of the data in the diff --git a/buffer/buffer_fromsa.c b/buffer/buffer_fromsa.c index ea4fb98..0227a32 100644 --- a/buffer/buffer_fromsa.c +++ b/buffer/buffer_fromsa.c @@ -1,6 +1,6 @@ #include "stralloc.h" #include "buffer.h" -void buffer_fromsa(buffer* b,stralloc* sa) { +void buffer_fromsa(buffer* b,const stralloc* sa) { buffer_frombuf(b,sa->s,sa->len); } diff --git a/buffer/buffer_putsa.3 b/buffer/buffer_putsa.3 index 3251acb..d2609fd 100644 --- a/buffer/buffer_putsa.3 +++ b/buffer/buffer_putsa.3 @@ -6,9 +6,9 @@ buffer_putsa \- write stralloc to buffer .B #include .B #include -int \fBbuffer_putsa\fP(buffer* \fIb\fR,stralloc* \fIx\fR); +int \fBbuffer_putsa\fP(buffer* \fIb\fR,const stralloc* \fIx\fR); .SH DESCRIPTION -buffer_putsa is equivalent to buffer_put(b,x.sa,x.len). +buffer_putsa is equivalent to buffer_put(b,x.s,x.len). .SH "RETURN VALUE" 0 if everything is fine, -1 on error (setting \fIerrno\fR). .SH "SEE ALSO" diff --git a/buffer/buffer_putsa.c b/buffer/buffer_putsa.c index f1e346b..f4d7f44 100644 --- a/buffer/buffer_putsa.c +++ b/buffer/buffer_putsa.c @@ -1,6 +1,6 @@ #include "stralloc.h" #include "buffer.h" -int buffer_putsa(buffer* b,stralloc* sa) { +int buffer_putsa(buffer* b,const stralloc* sa) { return buffer_put(b,sa->s,sa->len); } diff --git a/buffer/buffer_putsaflush.3 b/buffer/buffer_putsaflush.3 index aed30d6..b161f47 100644 --- a/buffer/buffer_putsaflush.3 +++ b/buffer/buffer_putsaflush.3 @@ -6,9 +6,9 @@ buffer_putsa \- write stralloc to buffer and flush .B #include .B #include -int \fBbuffer_putsaflush\fP(buffer* \fIb\fR,const char* \fIx\fR); +int \fBbuffer_putsaflush\fP(buffer* \fIb\fR,const stralloc* \fIx\fR); .SH DESCRIPTION -buffer_putsaflush is equivalent to buffer_putflush(b,x.sa,x.len). +buffer_putsaflush is equivalent to buffer_putflush(b,x.s,x.len). .SH "RETURN VALUE" 0 if everything is fine, -1 on error (setting \fIerrno\fR). .SH "SEE ALSO" diff --git a/buffer/buffer_putsaflush.c b/buffer/buffer_putsaflush.c index b3d2c54..44a8a31 100644 --- a/buffer/buffer_putsaflush.c +++ b/buffer/buffer_putsaflush.c @@ -1,6 +1,6 @@ #include "stralloc.h" #include "buffer.h" -int buffer_putsaflush(buffer* b,stralloc* sa) { +int buffer_putsaflush(buffer* b,const stralloc* sa) { return buffer_putflush(b,sa->s,sa->len); } diff --git a/stralloc.h b/stralloc.h index c66c04d..a96bf2c 100644 --- a/stralloc.h +++ b/stralloc.h @@ -76,7 +76,7 @@ int stralloc_catm_internal(stralloc* sa,...); #define stralloc_copym(sa,...) (stralloc_zero(sa), stralloc_catm_internal(sa,__VA_ARGS__,(char*)0)) /* stralloc_cat is analogous to stralloc_copy */ -int stralloc_cat(stralloc* sa,stralloc* in); +int stralloc_cat(stralloc* sa,const stralloc* in); /* stralloc_append adds one byte in[0] to the end of the string stored * in sa. It is the same as stralloc_catb(&sa,in,1). */ @@ -129,9 +129,9 @@ int stralloc_chomp(stralloc* sa); #ifdef BUFFER_H /* write stralloc to buffer */ -int buffer_putsa(buffer* b,stralloc* sa); +int buffer_putsa(buffer* b,const stralloc* sa); /* write stralloc to buffer and flush */ -int buffer_putsaflush(buffer* b,stralloc* sa); +int buffer_putsaflush(buffer* b,const stralloc* sa); /* these "read token" functions return 1 for a complete token, 0 if * EOF was hit or -1 on error. In contrast to the non-stralloc token @@ -164,7 +164,7 @@ int buffer_get_new_token_sa_pred(buffer* b,stralloc* sa,sa_predicate p); /* make a buffer (for reading) from a stralloc. * Do not change the stralloc after this! */ -void buffer_fromsa(buffer* b,stralloc* sa); +void buffer_fromsa(buffer* b,const stralloc* sa); int buffer_tosa(buffer*b,stralloc* sa); /* write to sa, auto-growing it */ #endif diff --git a/stralloc/stralloc_cat.3 b/stralloc/stralloc_cat.3 index f46bed8..df8166a 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 -int \fBstralloc_cat\fP(stralloc* \fIsato\fR,stralloc* \fIsafrom\fR); +int \fBstralloc_cat\fP(stralloc* \fIsato\fR,const 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_cat.c b/stralloc/stralloc_cat.c index 1c0666b..3beed10 100644 --- a/stralloc/stralloc_cat.c +++ b/stralloc/stralloc_cat.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "str.h" -extern int stralloc_cat(stralloc *sa,stralloc *sa2) { +extern int stralloc_cat(stralloc *sa,const stralloc *sa2) { return stralloc_catb(sa,sa2->s,sa2->len); }