test_sballoc improvements.
authorRobert Haas <rhaas@postgresql.org>
Wed, 26 Mar 2014 23:55:43 +0000 (16:55 -0700)
committerRobert Haas <rhaas@postgresql.org>
Wed, 26 Mar 2014 23:55:43 +0000 (16:55 -0700)
contrib/test_sballoc/test_sballoc.c

index 2357625084fb88d6a9b0e2d8e0b1c3d455c639b4..8a64fd93052d5e223c870e325b49786c9f82475e 100644 (file)
@@ -30,11 +30,16 @@ alloc(PG_FUNCTION_ARGS)
        int64 size = PG_GETARG_INT64(0);
        int64 count = PG_GETARG_INT64(1);
        int64 i;
+       int64 *p;
        sb_allocator *a;
 
        a = sb_create_private_allocator();
        for (i = 0; i < count; ++i)
-               (void) sb_alloc(a, size, 0);
+       {
+               p = sb_alloc(a, size, 0);
+               *p = i;
+       }
+       sb_reset_allocator(a);
 
        PG_RETURN_VOID();
 }
@@ -45,6 +50,7 @@ alloc_with_palloc(PG_FUNCTION_ARGS)
        int64 size = PG_GETARG_INT64(0);
        int64 count = PG_GETARG_INT64(1);
        int64 i;
+       int64 *p;
        MemoryContext context;
 
        context = AllocSetContextCreate(CurrentMemoryContext,
@@ -53,7 +59,10 @@ alloc_with_palloc(PG_FUNCTION_ARGS)
                                                                    ALLOCSET_DEFAULT_INITSIZE,
                                                                    ALLOCSET_DEFAULT_MAXSIZE);
        for (i = 0; i < count; ++i)
-               (void) MemoryContextAlloc(context, size);
+       {
+               p = MemoryContextAlloc(context, size);
+               *p = i;
+       }
 
        PG_RETURN_VOID();
 }