git » nmdb » commit 2103844

Implement some arguments checking in test2.

author Alberto Bertogli
2006-09-12 15:53:39 UTC
committer Alberto Bertogli
2006-09-12 15:53:39 UTC
parent e4099d106a270b3a790610dc76837c3214d00f6d

Implement some arguments checking in test2.

libnmdb/test2c.c +5 -0
libnmdb/test2d.c +5 -0

diff --git a/libnmdb/test2c.c b/libnmdb/test2c.c
index 0d98824..6570c1a 100644
--- a/libnmdb/test2c.c
+++ b/libnmdb/test2c.c
@@ -25,6 +25,11 @@ int main(int argc, char **argv)
 	times = atoi(argv[1]);
 	ksize = atoi(argv[2]);
 	vsize = atoi(argv[3]);
+	if (times < 1 || ksize < 1 || vsize < 1) {
+		printf("Error: TIMES, KSIZE and VSIZE must be >= 1\n");
+		return 1;
+	}
+
 	key = malloc(ksize);
 	memset(key, 0, ksize);
 	val = malloc(vsize);
diff --git a/libnmdb/test2d.c b/libnmdb/test2d.c
index 8ee48b5..e55b698 100644
--- a/libnmdb/test2d.c
+++ b/libnmdb/test2d.c
@@ -25,6 +25,11 @@ int main(int argc, char **argv)
 	times = atoi(argv[1]);
 	ksize = atoi(argv[2]);
 	vsize = atoi(argv[3]);
+	if (times < 1 || ksize < 1 || vsize < 1) {
+		printf("Error: TIMES, KSIZE and VSIZE must be >= 1\n");
+		return 1;
+	}
+
 	key = malloc(ksize);
 	memset(key, 0, ksize);
 	val = malloc(vsize);