Lines Matching refs:bp

49 dt_buf_create(dtrace_hdl_t *dtp, dt_buf_t *bp, const char *name, size_t len)  in dt_buf_create()  argument
54 bp->dbu_buf = bp->dbu_ptr = dt_zalloc(dtp, len); in dt_buf_create()
55 bp->dbu_len = len; in dt_buf_create()
57 if (bp->dbu_buf == NULL) in dt_buf_create()
58 bp->dbu_err = dtrace_errno(dtp); in dt_buf_create()
60 bp->dbu_err = 0; in dt_buf_create()
62 bp->dbu_resizes = 0; in dt_buf_create()
63 bp->dbu_name = name; in dt_buf_create()
67 dt_buf_destroy(dtrace_hdl_t *dtp, dt_buf_t *bp) in dt_buf_destroy() argument
70 bp->dbu_name, (ulong_t)bp->dbu_len, bp->dbu_resizes); in dt_buf_destroy()
72 dt_free(dtp, bp->dbu_buf); in dt_buf_destroy()
76 dt_buf_reset(dtrace_hdl_t *dtp, dt_buf_t *bp) in dt_buf_reset() argument
78 if ((bp->dbu_ptr = bp->dbu_buf) != NULL) in dt_buf_reset()
79 bp->dbu_err = 0; in dt_buf_reset()
81 dt_buf_create(dtp, bp, bp->dbu_name, bp->dbu_len); in dt_buf_reset()
85 dt_buf_write(dtrace_hdl_t *dtp, dt_buf_t *bp, in dt_buf_write() argument
88 size_t off = (size_t)(bp->dbu_ptr - bp->dbu_buf); in dt_buf_write()
91 if (bp->dbu_err != 0) { in dt_buf_write()
92 (void) dt_set_errno(dtp, bp->dbu_err); in dt_buf_write()
96 if (bp->dbu_ptr + adj + len > bp->dbu_buf + bp->dbu_len) { in dt_buf_write()
97 size_t new_len = bp->dbu_len * 2; in dt_buf_write()
101 while (bp->dbu_ptr + adj + len > bp->dbu_buf + new_len) { in dt_buf_write()
107 bp->dbu_err = dtrace_errno(dtp); in dt_buf_write()
111 bcopy(bp->dbu_buf, new_buf, off); in dt_buf_write()
112 dt_free(dtp, bp->dbu_buf); in dt_buf_write()
114 bp->dbu_buf = new_buf; in dt_buf_write()
115 bp->dbu_ptr = new_buf + off; in dt_buf_write()
116 bp->dbu_len = new_len; in dt_buf_write()
117 bp->dbu_resizes += r; in dt_buf_write()
120 bp->dbu_ptr += adj; in dt_buf_write()
121 bcopy(buf, bp->dbu_ptr, len); in dt_buf_write()
122 bp->dbu_ptr += len; in dt_buf_write()
139 dt_buf_offset(const dt_buf_t *bp, size_t align) in dt_buf_offset() argument
141 size_t off = (size_t)(bp->dbu_ptr - bp->dbu_buf); in dt_buf_offset()
146 dt_buf_len(const dt_buf_t *bp) in dt_buf_len() argument
148 return (bp->dbu_ptr - bp->dbu_buf); in dt_buf_len()
152 dt_buf_error(const dt_buf_t *bp) in dt_buf_error() argument
154 return (bp->dbu_err); in dt_buf_error()
158 dt_buf_ptr(const dt_buf_t *bp) in dt_buf_ptr() argument
160 return (bp->dbu_buf); in dt_buf_ptr()
164 dt_buf_claim(dtrace_hdl_t *dtp, dt_buf_t *bp) in dt_buf_claim() argument
166 void *buf = bp->dbu_buf; in dt_buf_claim()
168 if (bp->dbu_err != 0) { in dt_buf_claim()
173 bp->dbu_buf = bp->dbu_ptr = NULL; in dt_buf_claim()
174 bp->dbu_len = 0; in dt_buf_claim()