?? stralloc.3
字號(hào):
.TH stralloc 3.SH NAMEstralloc \- dynamically allocated strings.SH SYNTAX.B #include <stralloc.h>int \fBstralloc_ready\fP(&\fIsa\fR,\fIlen\fR);.brint \fBstralloc_readyplus\fP(&\fIsa\fR,\fIlen\fR);int \fBstralloc_copy\fP(&\fIsa\fR,&\fIsa2\fR);.brint \fBstralloc_copys\fP(&\fIsa\fR,\fIbuf\fR);.brint \fBstralloc_copyb\fP(&\fIsa\fR,\fIbuf\fR,\fIlen\fR);int \fBstralloc_cat\fP(&\fIsa\fR,&\fIsa2\fR);.brint \fBstralloc_cats\fP(&\fIsa\fR,\fIbuf\fR);.brint \fBstralloc_catb\fP(&\fIsa\fR,\fIbuf\fR,\fIlen\fR);int \fBstralloc_append\fP(&\fIsa\fR,\fIbuf\fR);.brint \fBstralloc_0\fP(&\fIsa\fR);int \fBstralloc_starts\fP(&\fIsa\fR,\fIbuf\fR);stralloc \fIsa\fR = {0};.brstralloc \fIsa2\fR = {0};.brunsigned int \fIlen\fR;.brchar *\fIbuf\fR;.SH DESCRIPTIONA.B strallocvariable holds a string in dynamically allocated space.String length is limited only by memory.String contents are unrestricted.The.B strallocstructure has three components:.I sa\fB.sis a pointer to the string, or 0 if it is not allocated;.I sa\fB.lenis the number of bytes in the string, if it is allocated;.I sa\fB.ais the number of bytes allocated for the string, if it is allocated.A.B strallocvariable should be initialized to {0},meaning unallocated..B stralloc_readymakes sure that.I sahas enough space allocated for.I lencharacters.It allocates extra space if necessary..B stralloc_readyplusmakes sure that.I sahas enough space allocated for.I lencharacters more than its current length.If.I sais unallocated,.B stralloc_readyplusis the same as.BR stralloc_ready ..B stralloc_copycopies.I sa2to.IR sa ,allocating space if necessary.Here.I sa2is an allocated.B strallocvariable..B stralloc_copyscopies a 0-terminated string,.IR buf ,to.IR sa ,without the 0..B stralloc_copybcopies.I lencharacters from.I bufto.IR sa ..B stralloc_catappends.I sa2to.IR sa ,allocating space if necessary.If.I sais unallocated,.B stralloc_catis the same as.BR stralloc_copy ..B stralloc_catsand.B stralloc_catbare analogous to.B stralloc_copysand.BR stralloc_copyb ..B stralloc_appendadds a single character,.IR *buf ,to.IR sa ,allocating space if necessary..B stralloc_0adds a single 0 characterto.IR sa ..B stralloc_startsreturns 1 if the 0-terminated string.IR buf ,without the 0,is a prefix of.IR sa ..SH "ERROR HANDLING"If a.B strallocroutine runs out of memory,it leaves.I saalone and returns 0,setting.B errnoappropriately.On success it returns 1;this guarantees that.I sais allocated..SH "SEE ALSO"alloc(3),error(3)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -