Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Extensive, Pedantic Error Checking in Linux module, especially for memory
[palacios.git] / linux_module / util-ringbuffer.c
index d52d25d..9d0935d 100644 (file)
 #include "util-ringbuffer.h"\r
 \r
 void init_ringbuf(struct ringbuf * ring, unsigned int size) {\r
-    ring->buf = kmalloc(size, GFP_KERNEL);\r
+    ring->buf = palacios_alloc(size);\r
+\r
+    if (!(ring->buf)) { \r
+       ERROR("Cannot allocate ring buffer data\n");\r
+       size=0;\r
+    }\r
+\r
     ring->size = size;\r
   \r
     ring->start = 0;\r
@@ -21,15 +27,21 @@ void init_ringbuf(struct ringbuf * ring, unsigned int size) {
 }\r
 \r
 struct ringbuf * create_ringbuf(unsigned int size) {\r
-    struct ringbuf * ring = (struct ringbuf *)kmalloc(sizeof(struct ringbuf), GFP_KERNEL);\r
+    struct ringbuf * ring = (struct ringbuf *)palacios_alloc(sizeof(struct ringbuf));\r
+\r
+    if (!ring) { \r
+       ERROR("Cannot allocate ring buffer\n");\r
+       return NULL;\r
+    }\r
+\r
     init_ringbuf(ring, size);\r
 \r
     return ring;\r
 }\r
 \r
 void free_ringbuf(struct ringbuf * ring) {\r
-    kfree(ring->buf);\r
-    kfree(ring);\r
+    palacios_free(ring->buf);\r
+    palacios_free(ring);\r
 }\r
 \r
 static inline unsigned char * get_read_ptr(struct ringbuf * ring) {\r