5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
23 * Revision 1.1 2000/06/27 11:36:55 priikone
29 #include "silcincludes.h"
31 #ifdef SILC_DEBUG /* If we are doing debugging we won't
32 have the optimized inline buffer functions
33 available as optimization is not set
34 to compiler. These normal routines are
35 used in debugging mode. */
37 /* Clears and initialiazes the buffer to the state as if it was just
38 allocated by silc_buffer_alloc. */
40 void silc_buffer_clear(SilcBuffer sb)
42 memset(sb->head, 0, sb->truelen);
48 /* Generates copy of a SilcBuffer. This copies everything inside the
49 currently valid data area, nothing more. Use silc_buffer_clone to
50 copy entire buffer. */
52 SilcBuffer silc_buffer_copy(SilcBuffer sb)
56 sb_new = silc_buffer_alloc(sb->len);
57 silc_buffer_pull_tail(sb_new, SILC_BUFFER_END(sb_new));
58 silc_buffer_put(sb_new, sb->data, sb->len);
63 /* Clones SilcBuffer. This generates new SilcBuffer and copies
64 everything from the source buffer. The result is exact clone of
65 the original buffer. */
67 SilcBuffer silc_buffer_clone(SilcBuffer sb)
71 sb_new = silc_buffer_alloc(sb->truelen);
72 silc_buffer_pull_tail(sb_new, SILC_BUFFER_END(sb_new));
73 silc_buffer_put(sb_new, sb->head, sb->truelen);
74 sb_new->data = sb_new->head + sb->len;
75 sb_new->tail = sb_new->head + (sb->end - sb->tail);
76 sb_new->len = sb->len;
81 #endif /* SILC_DEBUG */