Lines Matching full:len
59 buf->len = 0;
79 /* resize a buffer, pos and len will be repositioned if required when
89 buf->len = MIN(newsize, buf->len);
100 ret = buf_new(buf->len);
101 ret->len = buf->len;
102 memcpy(ret->data, buf->data, buf->len);
107 void buf_setlen(buffer* buf, unsigned int len) {
108 if (len > buf->size) {
111 buf->len = len;
116 if (incr > BUF_MAX_INCR || buf->len + incr > buf->size) {
119 buf->len += incr;
124 if (pos > buf->len) {
136 if (buf->pos > buf->len) {
137 buf->len = buf->pos;
145 (unsigned int)((int)buf->pos + incr) > buf->len
156 * bad case of pos > len, which should _never_ happen. */
157 if (buf->pos >= buf->len) {
176 if (buf->pos >= buf->len) {
184 * the next len bytes from that position can be used */
185 unsigned char* buf_getptr(buffer* buf, unsigned int len) {
187 if (buf->pos + len > buf->len) {
195 unsigned char* buf_getwriteptr(buffer* buf, unsigned int len) {
197 if (buf->pos + len > buf->size) {
208 unsigned int len;
210 len = buf_getint(buf);
211 if (len > MAX_STRING_LEN) {
216 *retlen = len;
218 ret = m_malloc(len+1);
219 memcpy(ret, buf_getptr(buf, len), len);
220 buf_incrpos(buf, len);
221 ret[len] = '\0';
250 /* put a SSH style string into the buffer, increasing buffer len if required */
251 void buf_putstring(buffer* buf, const unsigned char* str, unsigned int len) {
253 buf_putint(buf, len);
254 buf_putbytes(buf, str, len);
258 /* put the set of len bytes into the buffer, incrementing the pos, increasing
259 * len if required */
260 void buf_putbytes(buffer *buf, const unsigned char *bytes, unsigned int len) {
261 memcpy(buf_getwriteptr(buf, len), bytes, len);
262 buf_incrwritepos(buf, len);
270 unsigned int len, pad = 0;
281 len = 0;
285 len = mp_count_bits(mp);
287 pad = (len%8 == 0) ? 1 : 0;
288 len = len / 8 + 1; /* don't worry about rounding, we need it for
289 padding anyway when len%8 == 0 */
294 buf_putint(buf, len);
297 if (len > 0) {
301 if (mp_to_unsigned_bin(mp, buf_getwriteptr(buf, len-pad)) != MP_OKAY) {
304 buf_incrwritepos(buf, len-pad);
315 unsigned int len;
316 len = buf_getint(buf);
318 if (len == 0) {
323 if (len > BUF_MAX_MPINT) {
332 if (mp_read_unsigned_bin(mp, buf_getptr(buf, len), len) != MP_OKAY) {
336 buf_incrpos(buf, len);