From: Ezra Peisach Date: Thu, 27 Jun 1996 14:38:14 +0000 (+0000) Subject: * asn1buf.c (asn12krb5_buf): Initialize magic fields of structure. X-Git-Tag: krb5-1.0-beta7~324 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72e11ec4a1b3cd663e803ef28540870efcad0a92;p=thirdparty%2Fkrb5.git * asn1buf.c (asn12krb5_buf): Initialize magic fields of structure. (asn1buf_expand): If pre-allocating memory for future use, store proper end of buffer. This was a big performance hit in asn.1 routines as every time it tried to decode an octet, 200 bytes were allocated (for future use), but the buffer structure pnly thought that one byte was allocated and the next time through would try to allocate memory again. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8553 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index 377351ad1e..fe9fe37095 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,9 @@ +Thu Jun 27 10:31:34 1996 Ezra Peisach + + * asn1buf.c (asn12krb5_buf): Initialize magic fields of structure. + (asn1buf_expand): If pre-allocating memory for future use, store + proper end of buffer. + Wed Jun 12 14:25:11 1996 Theodore Ts'o * asn1_k_encode.h, asn1_k_decode.h: Add prototypes for the SAM diff --git a/src/lib/krb5/asn.1/asn1buf.c b/src/lib/krb5/asn.1/asn1buf.c index 327a9dfd5d..822b26377d 100644 --- a/src/lib/krb5/asn.1/asn1buf.c +++ b/src/lib/krb5/asn.1/asn1buf.c @@ -226,6 +226,7 @@ asn1_error_code asn12krb5_buf(buf, code) int i; *code = (krb5_data*)calloc(1,sizeof(krb5_data)); if(*code == NULL) return ENOMEM; + (*code)->magic = KV5M_DATA; (*code)->data = NULL; (*code)->length = 0; (*code)->length = asn1buf_len(buf); @@ -350,7 +351,8 @@ asn1_error_code asn1buf_expand(buf, inc) inc : STANDARD_INCREMENT)) * sizeof(asn1_octet)); if(buf->base == NULL) return ENOMEM; - buf->bound = (buf->base) + bound_offset + inc; + buf->bound = (buf->base) + bound_offset + (inc > STANDARD_INCREMENT ? + inc : STANDARD_INCREMENT); buf->next = (buf->base) + next_offset; return 0; }