Lines Matching refs:nmemb
46 int nghttp3_ringbuf_init(nghttp3_ringbuf *rb, size_t nmemb, size_t size,
48 if (nmemb) {
50 assert(1 == __popcnt((unsigned int)nmemb));
52 assert(1 == __builtin_popcount((unsigned int)nmemb));
55 rb->buf = nghttp3_mem_malloc(mem, nmemb * size);
64 rb->nmemb = nmemb;
81 rb->first = (rb->first - 1) & (rb->nmemb - 1);
82 rb->len = nghttp3_min(rb->nmemb, rb->len + 1);
88 size_t offset = (rb->first + rb->len) & (rb->nmemb - 1);
90 if (rb->len == rb->nmemb) {
91 rb->first = (rb->first + 1) & (rb->nmemb - 1);
100 rb->first = (rb->first + 1) & (rb->nmemb - 1);
110 assert(len <= rb->nmemb);
116 offset = (rb->first + offset) & (rb->nmemb - 1);
120 int nghttp3_ringbuf_full(nghttp3_ringbuf *rb) { return rb->len == rb->nmemb; }
122 int nghttp3_ringbuf_reserve(nghttp3_ringbuf *rb, size_t nmemb) {
125 if (rb->nmemb >= nmemb) {
130 assert(1 == __popcnt((unsigned int)nmemb));
132 assert(1 == __builtin_popcount((unsigned int)nmemb));
135 buf = nghttp3_mem_malloc(rb->mem, nmemb * rb->size);
141 if (rb->first + rb->len <= rb->nmemb) {
146 (rb->nmemb - rb->first) * rb->size);
147 memcpy(buf + (rb->nmemb - rb->first) * rb->size, rb->buf,
148 (rb->len - (rb->nmemb - rb->first)) * rb->size);
156 rb->nmemb = nmemb;