Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

bugfix: calc block size

  • Loading branch information...
commit 2ced0dcb10d85123b3ac2608021396631a4ee780 1 parent 88bde77
云风 authored

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. +3 3 ringbuffer.c
6 ringbuffer.c
@@ -88,7 +88,7 @@ ringbuffer_alloc(struct ringbuffer * rb, int size) {
88 88 do {
89 89 if (blk->length >= sizeof(struct ringbuffer_block) && blk->id >= 0)
90 90 return NULL;
91   - free_size += blk->length;
  91 + free_size += ALIGN(blk->length);
92 92 if (free_size >= align_length) {
93 93 return _alloc(rb, free_size , size);
94 94 }
@@ -210,7 +210,7 @@ ringbuffer_copy(struct ringbuffer * rb, struct ringbuffer_block * from, int skip
210 210 assert(from->offset == 0);
211 211 ptr += length;
212 212 size -= length;
213   - length = from->length;
  213 + length = from->length - sizeof(struct ringbuffer_block);
214 214 src = (char *)(from + 1);
215 215 }
216 216 memcpy(ptr, src , size);
@@ -254,7 +254,7 @@ ringbuffer_dump(struct ringbuffer * rb) {
254 254 if (i>10)
255 255 break;
256 256 if (blk->length >= sizeof(*blk)) {
257   - printf("[%lu : %d]", blk->length - sizeof(*blk), block_offset(rb,blk));
  257 + printf("[%u : %d]", (unsigned)(blk->length - sizeof(*blk)), block_offset(rb,blk));
258 258 printf(" id=%d",blk->id);
259 259 if (blk->id >=0) {
260 260 printf(" offset=%d next=%d",blk->offset, blk->next);

0 comments on commit 2ced0dc

Please sign in to comment.
Something went wrong with that request. Please try again.