Lines Matching refs:bp
47 dt_buf_create(dtrace_hdl_t *dtp, dt_buf_t *bp, const char *name, size_t len) in dt_buf_create() argument
52 bp->dbu_buf = bp->dbu_ptr = dt_zalloc(dtp, len); in dt_buf_create()
53 bp->dbu_len = len; in dt_buf_create()
55 if (bp->dbu_buf == NULL) in dt_buf_create()
56 bp->dbu_err = dtrace_errno(dtp); in dt_buf_create()
58 bp->dbu_err = 0; in dt_buf_create()
60 bp->dbu_resizes = 0; in dt_buf_create()
61 bp->dbu_name = name; in dt_buf_create()
65 dt_buf_destroy(dtrace_hdl_t *dtp, dt_buf_t *bp) in dt_buf_destroy() argument
68 bp->dbu_name, (ulong_t)bp->dbu_len, bp->dbu_resizes); in dt_buf_destroy()
70 dt_free(dtp, bp->dbu_buf); in dt_buf_destroy()
74 dt_buf_reset(dtrace_hdl_t *dtp, dt_buf_t *bp) in dt_buf_reset() argument
76 if ((bp->dbu_ptr = bp->dbu_buf) != NULL) in dt_buf_reset()
77 bp->dbu_err = 0; in dt_buf_reset()
79 dt_buf_create(dtp, bp, bp->dbu_name, bp->dbu_len); in dt_buf_reset()
83 dt_buf_write(dtrace_hdl_t *dtp, dt_buf_t *bp, in dt_buf_write() argument
86 size_t off = (size_t)(bp->dbu_ptr - bp->dbu_buf); in dt_buf_write()
89 if (bp->dbu_err != 0) { in dt_buf_write()
90 (void) dt_set_errno(dtp, bp->dbu_err); in dt_buf_write()
94 if (bp->dbu_ptr + adj + len > bp->dbu_buf + bp->dbu_len) { in dt_buf_write()
95 size_t new_len = bp->dbu_len * 2; in dt_buf_write()
99 while (bp->dbu_ptr + adj + len > bp->dbu_buf + new_len) { in dt_buf_write()
105 bp->dbu_err = dtrace_errno(dtp); in dt_buf_write()
109 bcopy(bp->dbu_buf, new_buf, off); in dt_buf_write()
110 dt_free(dtp, bp->dbu_buf); in dt_buf_write()
112 bp->dbu_buf = new_buf; in dt_buf_write()
113 bp->dbu_ptr = new_buf + off; in dt_buf_write()
114 bp->dbu_len = new_len; in dt_buf_write()
115 bp->dbu_resizes += r; in dt_buf_write()
118 bp->dbu_ptr += adj; in dt_buf_write()
119 bcopy(buf, bp->dbu_ptr, len); in dt_buf_write()
120 bp->dbu_ptr += len; in dt_buf_write()
137 dt_buf_offset(const dt_buf_t *bp, size_t align) in dt_buf_offset() argument
139 size_t off = (size_t)(bp->dbu_ptr - bp->dbu_buf); in dt_buf_offset()
144 dt_buf_len(const dt_buf_t *bp) in dt_buf_len() argument
146 return (bp->dbu_ptr - bp->dbu_buf); in dt_buf_len()
150 dt_buf_error(const dt_buf_t *bp) in dt_buf_error() argument
152 return (bp->dbu_err); in dt_buf_error()
156 dt_buf_ptr(const dt_buf_t *bp) in dt_buf_ptr() argument
158 return (bp->dbu_buf); in dt_buf_ptr()
162 dt_buf_claim(dtrace_hdl_t *dtp, dt_buf_t *bp) in dt_buf_claim() argument
164 void *buf = bp->dbu_buf; in dt_buf_claim()
166 if (bp->dbu_err != 0) { in dt_buf_claim()
171 bp->dbu_buf = bp->dbu_ptr = NULL; in dt_buf_claim()
172 bp->dbu_len = 0; in dt_buf_claim()