projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Hide internal session configuration symbols
[lttng-tools.git]
/
src
/
common
/
dynamic-buffer.c
diff --git
a/src/common/dynamic-buffer.c
b/src/common/dynamic-buffer.c
index 9ed16514fe64fa84dc735f15de862ca662a04fef..fd39f813b3c2568beec2dff1be91343161ec8517 100644
(file)
--- a/
src/common/dynamic-buffer.c
+++ b/
src/common/dynamic-buffer.c
@@
-16,10
+16,13
@@
*/
#include <common/dynamic-buffer.h>
*/
#include <common/dynamic-buffer.h>
-#include <common/macros.h>
#include <common/utils.h>
#include <assert.h>
#include <common/utils.h>
#include <assert.h>
+/*
+ * Round to (upper) power of two, val is returned if it already is a power of
+ * two.
+ */
static
size_t round_to_power_of_2(size_t val)
{
static
size_t round_to_power_of_2(size_t val)
{
@@
-34,12
+37,14
@@
size_t round_to_power_of_2(size_t val)
return rounded;
}
return rounded;
}
+LTTNG_HIDDEN
void lttng_dynamic_buffer_init(struct lttng_dynamic_buffer *buffer)
{
assert(buffer);
memset(buffer, 0, sizeof(*buffer));
}
void lttng_dynamic_buffer_init(struct lttng_dynamic_buffer *buffer)
{
assert(buffer);
memset(buffer, 0, sizeof(*buffer));
}
+LTTNG_HIDDEN
int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
const void *buf, size_t len)
{
int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
const void *buf, size_t len)
{
@@
-55,11
+60,11
@@
int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
goto end;
}
goto end;
}
- assert(buffer->capacity >= buffer->size);
- if (buffer->capacity < (len + buffer->size)) {
+ assert(buffer->
_
capacity >= buffer->size);
+ if (buffer->
_
capacity < (len + buffer->size)) {
ret = lttng_dynamic_buffer_set_capacity(buffer,
ret = lttng_dynamic_buffer_set_capacity(buffer,
- buffer->capacity +
- (len - (buffer->capacity - buffer->size)));
+ buffer->
_
capacity +
+ (len - (buffer->
_
capacity - buffer->size)));
if (ret) {
goto end;
}
if (ret) {
goto end;
}
@@
-71,6
+76,7
@@
end:
return ret;
}
return ret;
}
+LTTNG_HIDDEN
int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
struct lttng_dynamic_buffer *src_buffer)
{
int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
struct lttng_dynamic_buffer *src_buffer)
{
@@
-87,6
+93,7
@@
end:
return ret;
}
return ret;
}
+LTTNG_HIDDEN
int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
size_t new_size)
{
int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
size_t new_size)
{
@@
-100,9
+107,9
@@
int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
goto end;
}
goto end;
}
- if (new_size > buffer->capacity) {
+ if (new_size > buffer->
_
capacity) {
size_t original_size = buffer->size;
size_t original_size = buffer->size;
- size_t original_capacity = buffer->capacity;
+ size_t original_capacity = buffer->
_
capacity;
ret = lttng_dynamic_buffer_set_capacity(buffer, new_size);
if (ret) {
ret = lttng_dynamic_buffer_set_capacity(buffer, new_size);
if (ret) {
@@
-135,6
+142,7
@@
end:
return ret;
}
return ret;
}
+LTTNG_HIDDEN
int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
size_t demanded_capacity)
{
int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
size_t demanded_capacity)
{
@@
-151,7
+159,7
@@
int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
goto end;
}
goto end;
}
- if (new_capacity == buffer->capacity) {
+ if (new_capacity == buffer->
_
capacity) {
goto end;
}
goto end;
}
@@
-162,18
+170,19
@@
int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
goto end;
}
buffer->data = new_buf;
goto end;
}
buffer->data = new_buf;
- buffer->capacity = new_capacity;
+ buffer->
_
capacity = new_capacity;
end:
return ret;
}
/* Release any memory used by the dynamic buffer. */
end:
return ret;
}
/* Release any memory used by the dynamic buffer. */
+LTTNG_HIDDEN
void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer)
{
if (!buffer) {
return;
}
buffer->size = 0;
void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer)
{
if (!buffer) {
return;
}
buffer->size = 0;
- buffer->capacity = 0;
+ buffer->
_
capacity = 0;
free(buffer->data);
}
free(buffer->data);
}
This page took
0.026795 seconds
and
5
git commands to generate.