/*
 * James O'Connor 2012
 * Proof of concept code for memory leak in libcouchbase_create / libcouchbase_destroy 
 * tested against libcouchbase 1.0.2 .
 * Use valgrind to observe leaked memory
 * 
 */

#include <unistd.h>
#include <getopt.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>

#include <libcouchbase/couchbase.h>

int main(int argc, char **argv)
{
	char *host = "a:8091;b:8091;c:8091;d:8091;e:8091;f:8091;";
	char *username = "admin";
	char *passwd = "password";
	char *bucket = "default";
	
	struct libcouchbase_io_opt_st * io = NULL;
	libcouchbase_t instance = NULL;
	int i=0;
	for(i=0; i<100; i++)
	{    
    	io = libcouchbase_create_io_ops(LIBCOUCHBASE_IO_OPS_DEFAULT, NULL, NULL);
        instance = libcouchbase_create(host, username, passwd, bucket, io);

		libcouchbase_destroy(instance);
	}
	return 0;
}
