X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Futil-ringbuffer.c;h=9d0935db605a28aa4ebc88979228876cf31f1398;hb=0246f0904a4800dbe1e8e23332d49b468a58f751;hp=53071e8b26b670c2b9268721d012ea33ef6abc3b;hpb=276cfa264720edddc1677e35c6a300596965de7d;p=palacios.git diff --git a/linux_module/util-ringbuffer.c b/linux_module/util-ringbuffer.c index 53071e8..9d0935d 100644 --- a/linux_module/util-ringbuffer.c +++ b/linux_module/util-ringbuffer.c @@ -1,7 +1,9 @@ -/* - * Ringbuffer Routines for VM - * (c) Lei Xia, 2010 +/* + * Ringbuffer implementation + * (c) Lei Xia 2010 */ + + #include #include #include @@ -10,7 +12,13 @@ #include "util-ringbuffer.h" void init_ringbuf(struct ringbuf * ring, unsigned int size) { - ring->buf = kmalloc(size, GFP_KERNEL); + ring->buf = palacios_alloc(size); + + if (!(ring->buf)) { + ERROR("Cannot allocate ring buffer data\n"); + size=0; + } + ring->size = size; ring->start = 0; @@ -19,15 +27,21 @@ void init_ringbuf(struct ringbuf * ring, unsigned int size) { } struct ringbuf * create_ringbuf(unsigned int size) { - struct ringbuf * ring = (struct ringbuf *)kmalloc(sizeof(struct ringbuf), GFP_KERNEL); + struct ringbuf * ring = (struct ringbuf *)palacios_alloc(sizeof(struct ringbuf)); + + if (!ring) { + ERROR("Cannot allocate ring buffer\n"); + return NULL; + } + init_ringbuf(ring, size); return ring; } void free_ringbuf(struct ringbuf * ring) { - kfree(ring->buf); - kfree(ring); + palacios_free(ring->buf); + palacios_free(ring); } static inline unsigned char * get_read_ptr(struct ringbuf * ring) {