buffer.c revision 02c335c23bf5fa225a467c19f2c063fb0dc7b8c3
/* Copyright (c) 2002-2016 Dovecot authors, see the included COPYING file */
/* @UNSAFE: whole file */
#include "lib.h"
#include "buffer.h"
struct real_buffer {
/* public: */
const unsigned char *r_buffer;
/* private: */
unsigned char *w_buffer;
unsigned int alloced:1;
unsigned int dynamic:1;
};
typedef int buffer_check_sizes[COMPILE_ERROR_IF_TRUE(sizeof(struct real_buffer) > sizeof(buffer_t)) ?1:1];
{
return;
}
static inline void
{
unsigned int extra;
}
/* 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
frame. */
}
}
#if 0
void *new_buf;
/* 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 */
}
#endif
}
{
struct real_buffer *buf;
/* clear the whole memory area. unnecessary usually, but if the
buffer is used by e.g. str_c() it tries to access uninitialized
memory */
}
{
struct real_buffer *buf;
}
{
struct real_buffer *buf;
}
{
}
{
void *data;
return data;
}
{
}
{
buffer_set_used_size(buf, 0);
}
{
}
{
}
{
}
{
else {
}
}
{
return;
/* delete from between */
} else {
/* delete the rest of the buffer */
end_size = 0;
}
}
{
}
{
}
{
else {
}
}
{
} else {
}
}
{
}
{
}
{
}
{
if (used_size_r != NULL)
}
{
}
{
}
{
/* 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. */
}
{
return FALSE;
}
{
void *ret;
/* this doesn't really do anything except verify the
stack frame */
}
}