MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sbuf_extend

Function sbuf_extend

freebsd/kern/subr_sbuf.c:168–188  ·  view source on GitHub ↗

* Extend an sbuf. */

Source from the content-addressed store, hash-verified

166 * Extend an sbuf.
167 */
168static int
169sbuf_extend(struct sbuf *s, int addlen)
170{
171 char *newbuf;
172 int newsize;
173
174 if (!SBUF_CANEXTEND(s))
175 return (-1);
176 newsize = sbuf_extendsize(s->s_size + addlen);
177 newbuf = SBMALLOC(newsize, SBUF_MALLOCFLAG(s));
178 if (newbuf == NULL)
179 return (-1);
180 memcpy(newbuf, s->s_buf, s->s_size);
181 if (SBUF_ISDYNAMIC(s))
182 SBFREE(s->s_buf);
183 else
184 SBUF_SETFLAG(s, SBUF_DYNAMIC);
185 s->s_buf = newbuf;
186 s->s_size = newsize;
187 return (0);
188}
189
190/*
191 * Initialize an sbuf.

Callers 4

sbuf_put_bytesFunction · 0.85
sbuf_bcopyinFunction · 0.85
sbuf_copyinFunction · 0.85
sbuf_vprintfFunction · 0.85

Calls 2

sbuf_extendsizeFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected