buffer.h (dovecot-2.3.16) | : | buffer.h (dovecot-2.3.17) | ||
---|---|---|---|---|
#ifndef BUFFER_H | #ifndef BUFFER_H | |||
#define BUFFER_H | #define BUFFER_H | |||
struct buffer { | struct buffer { | |||
union { | union { | |||
struct { | struct { | |||
const void *data; | const void *data; | |||
const size_t used; | const size_t used; | |||
}; | }; | |||
void *priv[8]; | void *priv[9]; | |||
}; | }; | |||
}; | }; | |||
/* WARNING: Be careful with functions that return pointers to data. | /* WARNING: Be careful with functions that return pointers to data. | |||
With dynamic buffers they are valid only as long as buffer is not | With dynamic buffers they are valid only as long as buffer is not | |||
realloc()ed. You shouldn't rely on it being valid if you have modified | realloc()ed. You shouldn't rely on it being valid if you have modified | |||
buffer in any way. */ | buffer in any way. */ | |||
/* Create a modifiable buffer from given data. Writes past this size will | /* Create a modifiable buffer from given data. Writes past this size will | |||
i_panic(). */ | i_panic(). */ | |||
skipping to change at line 38 | skipping to change at line 38 | |||
buffer_create_from_data((b), (d), (s))) | buffer_create_from_data((b), (d), (s))) | |||
#define buffer_create_from_const_data(b,d,s) \ | #define buffer_create_from_const_data(b,d,s) \ | |||
TYPE_CHECKS(void, \ | TYPE_CHECKS(void, \ | |||
COMPILE_ERROR_IF_TRUE(__builtin_object_size((d),1) < ((s)>0?(s):1)), \ | COMPILE_ERROR_IF_TRUE(__builtin_object_size((d),1) < ((s)>0?(s):1)), \ | |||
buffer_create_from_const_data((b), (d), (s))) | buffer_create_from_const_data((b), (d), (s))) | |||
/* Creates a dynamically growing buffer. Whenever write would exceed the | /* Creates a dynamically growing buffer. Whenever write would exceed the | |||
current size it's grown. */ | current size it's grown. */ | |||
buffer_t *buffer_create_dynamic(pool_t pool, size_t init_size); | buffer_t *buffer_create_dynamic(pool_t pool, size_t init_size); | |||
/* Create a dynamically growing buffer with a maximum size. Writes past the | /* Create a dynamically growing buffer with a maximum size. Writes past the | |||
maximum size will i_panic(). */ | maximum size will i_panic(). Internally allow it to grow max_size+1 so | |||
str_c() NUL can be used. */ | ||||
buffer_t *buffer_create_dynamic_max(pool_t pool, size_t init_size, | buffer_t *buffer_create_dynamic_max(pool_t pool, size_t init_size, | |||
size_t max_size); | size_t max_size); | |||
#define t_buffer_create(init_size) \ | #define t_buffer_create(init_size) \ | |||
buffer_create_dynamic(pool_datastack_create(), (init_size)) | buffer_create_dynamic(pool_datastack_create(), (init_size)) | |||
/* Free the memory used by buffer. Not needed if the memory is free'd | /* Free the memory used by buffer. Not needed if the memory is free'd | |||
directly from the memory pool. */ | directly from the memory pool. */ | |||
void buffer_free(buffer_t **buf); | void buffer_free(buffer_t **buf); | |||
/* Free the memory used by buffer structure, but return the buffer data | /* Free the memory used by buffer structure, but return the buffer data | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 3 lines changed or added |