Lines Matching refs:len
361 int len;
365 len = s->s_drain_func(s->s_drain_arg, s->s_buf, s->s_len);
366 if (len < 0) {
367 s->s_error = -len;
370 KASSERT(len > 0 && len <= s->s_len,
371 ("Bad drain amount %d for sbuf %p", len, s));
372 s->s_len -= len;
383 memmove(s->s_buf, s->s_buf + len, s->s_len);
393 sbuf_put_bytes(struct sbuf *s, const char *buf, size_t len)
402 while (len > 0) {
410 else if (sbuf_extend(s, len > INT_MAX ? INT_MAX : len)
417 if (len < n)
418 n = len;
423 len -= n;
439 sbuf_bcat(struct sbuf *s, const void *buf, size_t len)
442 sbuf_put_bytes(s, buf, len);
453 sbuf_bcopyin(struct sbuf *s, const void *uaddr, size_t len)
463 if (len == 0)
465 if (len > SBUF_FREESPACE(s)) {
466 sbuf_extend(s, len - SBUF_FREESPACE(s));
467 if (SBUF_FREESPACE(s) < len)
468 len = SBUF_FREESPACE(s);
470 if (copyin(uaddr, s->s_buf + s->s_len, len) != 0)
472 s->s_len += len;
482 sbuf_bcpy(struct sbuf *s, const void *buf, size_t len)
489 return (sbuf_bcat(s, buf, len));
512 sbuf_copyin(struct sbuf *s, const void *uaddr, size_t len)
524 if (len == 0)
525 len = SBUF_FREESPACE(s); /* XXX return 0? */
526 if (len > SBUF_FREESPACE(s)) {
527 sbuf_extend(s, len);
528 if (SBUF_FREESPACE(s) < len)
529 len = SBUF_FREESPACE(s);
531 switch (copyinstr(uaddr, s->s_buf + s->s_len, len + 1, &done)) {
599 int error, len;
624 len = vsnprintf(&s->s_buf[s->s_len], SBUF_FREESPACE(s) + 1,
626 if (len < 0) {
632 if (SBUF_FREESPACE(s) >= len)
638 error = sbuf_extend(s, len - SBUF_FREESPACE(s));
650 if (SBUF_FREESPACE(s) < len)
651 len = SBUF_FREESPACE(s);
652 s->s_len += len;
654 s->s_sect_len += len;
788 /* If finished, nulterm is already in len, else add one. */
854 ssize_t len;
862 len = roundup(s->s_sect_len, pad) - s->s_sect_len;
863 for (; s->s_error == 0 && len > 0; len--)
866 len = s->s_sect_len;
875 return (len);