buffer.c revision 1a6ff0beebf0ab0c71081eaff1d5d7fd26015a94
781N/A/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */ 781N/A/* @UNSAFE: whole file */ /* clear used..dirty area */ /* always keep +1 byte allocated available in case str_c() is called for this buffer. this is mainly for cases where the buffer is allocated from data stack, and str_c() is called in a separate stack /* buffer's size increased: move the buffer's memory elsewhere. this should help catch bugs where old pointers are tried to be used to access the buffer's memory */ /* clear the whole memory area. unnecessary usually, but if the buffer is used by e.g. str_c() it tries to access uninitialized /* buffer_alloc() reserves +1 for str_c() NIL, so add +1 here to init_size so we can actually write that much to the buffer without /* delete from between */ /* delete the rest of the buffer */ /* we reserve +1 for str_c() NUL in buffer_check_limits(), so don't include that in our return value. otherwise the caller might increase the buffer's alloc size unnecessarily when it just wants to access the entire buffer. */ /* this doesn't really do anything except verify the /* no-op if it's shorten than bits in any case.. */ /* truncate it to closest byte boundary */ /* right shift over byte array */