output_buffer: only realloc once, and memset just what we need
[fio.git] / smalloc.c
index b460d6573bbc4e081a394a76808a18e5ee705ab7..8412e7518464d6dbe3e7f218e33e47e855e8e26f 100644 (file)
--- a/smalloc.c
+++ b/smalloc.c
@@ -32,7 +32,9 @@
 #define SMALLOC_POST_RED       0x5aa55aa5U
 
 unsigned int smalloc_pool_size = INITIAL_SIZE;
+#ifdef SMALLOC_REDZONE
 static const int int_mask = sizeof(int) - 1;
+#endif
 
 struct pool {
        struct fio_mutex *lock;                 /* protects this pool */
@@ -363,8 +365,12 @@ void sfree(void *ptr)
 
        global_read_unlock();
 
-       assert(pool);
-       sfree_pool(pool, ptr);
+       if (pool) {
+               sfree_pool(pool, ptr);
+               return;
+       }
+
+       log_err("smalloc: ptr %p not from smalloc pool\n", ptr);
 }
 
 static void *__smalloc_pool(struct pool *pool, size_t size)
@@ -486,13 +492,7 @@ void *smalloc(size_t size)
 
 void *scalloc(size_t nmemb, size_t size)
 {
-       void *ret;
-
-       ret = smalloc(nmemb * size);
-       if (ret)
-               memset(ret, 0, nmemb * size);
-
-       return ret;
+       return smalloc(nmemb * size);
 }
 
 char *smalloc_strdup(const char *str)