From: Pekka Riikonen Date: Sun, 17 Jun 2007 10:16:39 +0000 (+0000) Subject: unaligned SilcStack allocation changed to aligned allocation. X-Git-Tag: silc.toolkit.1.1.1~15 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=8d95a13700647af29810a7be76db757e792d0b34 unaligned SilcStack allocation changed to aligned allocation. --- diff --git a/lib/silcasn1/silcasn1_decode.c b/lib/silcasn1/silcasn1_decode.c index 21c39f8c..3030d07c 100644 --- a/lib/silcasn1/silcasn1_decode.c +++ b/lib/silcasn1/silcasn1_decode.c @@ -230,7 +230,7 @@ static SilcBool silc_asn1_decoder_sof(SilcAsn1 asn1, SilcBuffer src) ret = FALSE; \ goto fail; \ } \ - *s = silc_smalloc_ua(stack1, *s_len + 1); \ + *s = silc_smalloc(stack1, *s_len + 1); \ if (*s) { \ silc_utf8_encode(rdata, rdata_len, (enc), *s, *s_len); \ (*s)[*s_len] = '\0'; \ diff --git a/lib/silcasn1/silcasn1_encode.c b/lib/silcasn1/silcasn1_encode.c index 63b455cc..11b963ec 100644 --- a/lib/silcasn1/silcasn1_encode.c +++ b/lib/silcasn1/silcasn1_encode.c @@ -38,7 +38,7 @@ goto fail; \ } \ silc_stack_push(asn1->stack2, &frame); \ - s = silc_smalloc_ua(stack2, s_len + 1); \ + s = silc_smalloc(stack2, s_len + 1); \ if (s) { \ silc_utf8_decode(d, d_len, (enc), s, s_len); \ s[s_len] = '\0'; \ diff --git a/lib/silcutil/silcbuffer.h b/lib/silcutil/silcbuffer.h index ff9efe31..5ce67117 100644 --- a/lib/silcutil/silcbuffer.h +++ b/lib/silcutil/silcbuffer.h @@ -977,7 +977,7 @@ SilcBuffer silc_buffer_salloc(SilcStack stack, SilcUInt32 len) return NULL; /* Allocate the actual data area */ - sb->head = (unsigned char *)silc_smalloc_ua(stack, len); + sb->head = (unsigned char *)silc_smalloc(stack, len); if (silc_unlikely(!sb->head)) return NULL; @@ -1054,12 +1054,12 @@ SilcBuffer silc_buffer_srealloc(SilcStack stack, hlen = silc_buffer_headlen(sb); dlen = silc_buffer_len(sb); - h = (unsigned char *)silc_srealloc_ua(stack, silc_buffer_truelen(sb), - sb->head, newsize); + h = (unsigned char *)silc_srealloc(stack, silc_buffer_truelen(sb), + sb->head, newsize); if (!h) { /* Do slow and stack wasting realloc. The old sb->head is lost and is freed eventually. */ - h = (unsigned char *)silc_smalloc_ua(stack, newsize); + h = (unsigned char *)silc_smalloc(stack, newsize); if (silc_unlikely(!h)) return NULL; memcpy(h, sb->head, silc_buffer_truelen(sb)); diff --git a/lib/silcutil/silcbuffmt.c b/lib/silcutil/silcbuffmt.c index abcc65f4..bbb923e8 100644 --- a/lib/silcutil/silcbuffmt.c +++ b/lib/silcutil/silcbuffmt.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2006 Pekka Riikonen + Copyright (C) 1997 - 2007 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -747,8 +747,8 @@ int silc_buffer_sstrformat(SilcStack stack, SilcBuffer dst, ...) goto ok; slen = strlen(string); - d = silc_srealloc_ua(stack, len + 1, dst->head, - sizeof(*dst->head) * (slen + len + 1)); + d = silc_srealloc(stack, len + 1, dst->head, + sizeof(*dst->head) * (slen + len + 1)); if (silc_unlikely(!d)) return -1; dst->head = d; diff --git a/lib/silcutil/silcstack.h b/lib/silcutil/silcstack.h index b10bb600..3543de2a 100644 --- a/lib/silcutil/silcstack.h +++ b/lib/silcutil/silcstack.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2003 - 2006 Pekka Riikonen + Copyright (C) 2003 - 2007 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,6 +48,7 @@ * * The data stack is not thread-safe. If the same stack context must be * used in multithreaded environment concurrency control must be employed. + * Each thread should allocate their own SilcStack. * ***/ @@ -81,11 +82,11 @@ typedef struct SilcStackStruct *SilcStack; * Static stack frame context that optionally can be used as stack * frame in SilcStack. By default silc_stack_push use pre-allocated * stack frame (or allocates new one if all frames are reserved), but - * user may also use staticly allocated SilcStackFrame instead. This + * user may also use statically allocated SilcStackFrame instead. This * is recommended when using SilcStack in recursive routine and the * recursion may become deep. Using static frame assures that during * recursion frames never run out and silc_stack_push never allocates - * any memory. In other normal usage staticly allocated SilcStackFrame + * any memory. In other normal usage statically allocated SilcStackFrame * is not needed, unless performance is critical. * ***/ @@ -142,10 +143,10 @@ void silc_stack_free(SilcStack stack); * If this returns zero (0) the system is out of memory. * * If the `frame' is non-NULL then that SilcStackFrame is used as - * stack frame. Usually `frame' is set to NULL by user. Staticly + * stack frame. Usually `frame' is set to NULL by user. Statically * allocated SilcStackFrame should be used when using silc_stack_push * in recursive function and the recursion may become deep. In this - * case using staticly allocated SilcStackFrame is recommended since + * case using statically allocated SilcStackFrame is recommended since * it assures that frames never run out and silc_stack_push never * allocates any memory. If your routine is not recursive then * setting `frame' to NULL is recommended, unless performance is @@ -169,8 +170,8 @@ void silc_stack_free(SilcStack stack); * silc_foo_parse_packet(packet, stack); * silc_stack_pop(stack); * - * Another example with recursion and using staticly allocated - * SilcStackFrame. After popping the staticly allocated frame can + * Another example with recursion and using statically allocated + * SilcStackFrame. After popping the statically allocated frame can * be reused if necessary. * * void silc_foo_this_function(SilcStack stack)