MCPcopy Create free account
hub / github.com/apache/qpid-proton / pn_buffer_ensure

Function pn_buffer_ensure

c/src/core/buffer.c:116–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116int pn_buffer_ensure(pn_buffer_t *buf, size_t size)
117{
118 size_t old_capacity = buf->capacity;
119 size_t old_head = pni_buffer_head(buf);
120 bool wrapped = pni_buffer_wrapped(buf);
121
122 while (pn_buffer_available(buf) < size) {
123 buf->capacity = 2*(buf->capacity ? buf->capacity : 16);
124 }
125
126 if (buf->capacity != old_capacity) {
127 char* new_bytes = (char *) pni_mem_subreallocate(PN_CLASSCLASS(pn_buffer), buf, buf->bytes, buf->capacity);
128 if (new_bytes) {
129 buf->bytes = new_bytes;
130
131 if (wrapped) {
132 size_t n = old_capacity - old_head;
133 memmove(buf->bytes + buf->capacity - n, buf->bytes + old_head, n);
134 buf->start = buf->capacity - n;
135 }
136 }
137 }
138
139 return 0;
140}
141
142int pn_buffer_append(pn_buffer_t *buf, const char *bytes, size_t size)
143{

Callers 5

pn_buffer_appendFunction · 0.85
pn_post_frameFunction · 0.85
pni_pump_inFunction · 0.85
pn_messenger_putFunction · 0.85
grow_inbuf2Function · 0.85

Calls 4

pni_buffer_headFunction · 0.85
pni_buffer_wrappedFunction · 0.85
pn_buffer_availableFunction · 0.85
pni_mem_subreallocateFunction · 0.85

Tested by

no test coverage detected