R_API ut8 *r_buf_read_all(RBuffer *b, int *blen) {
	r_return_val_if_fail (b, NULL);
	int buflen = r_buf_size (b);
	if (buflen < 0) {
		return NULL;
	}
	ut8 *buf = malloc (buflen + 1);
	buf_seek (b, 0, R_BUF_SET);
	buf_read (b, buf, buflen);
	if (blen) {
		*blen = buflen;
	}
	return buf;
}
R_API ut8 *r_buf_read_all(RBuffer *b, int *blen) {
	r_return_val_if_fail (b, NULL);
	int buflen = r_buf_size (b);
	if (buflen < 0) {
		return NULL;
	}
	ut8 *buf = malloc (buflen + 1);
	buf_seek (b, 0, R_BUF_SET);
	buf_read (b, buf, buflen);
	if (blen) {
		*blen = buflen;
	}
	return buf;
}