Introduced 4 macros to minimise boilerplate command line processing code.
Nicely cuts around 130 lines of code, spread over the core and several tools.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2422 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/massif/ms_main.c b/massif/ms_main.c
index a0165cd..584da10 100644
--- a/massif/ms_main.c
+++ b/massif/ms_main.c
@@ -290,30 +290,11 @@
Bool SK_(process_cmd_line_option)(Char* arg)
{
- if (VG_CLO_STREQ(arg, "--heap=yes"))
- clo_heap = True;
- else if (VG_CLO_STREQ(arg, "--heap=no"))
- clo_heap = False;
+ VG_BOOL_CLO("--heap", clo_heap)
+ else VG_BOOL_CLO("--stacks", clo_stacks)
- else if (VG_CLO_STREQN(13, arg, "--heap-admin=")) {
- clo_heap_admin = (Int)VG_(atoll)(&arg[13]);
- if (clo_heap_admin > 100) {
- VG_(message)(Vg_UserMsg,
- "Admin size for heap blocks too large");
- VG_(bad_option)(arg);
- }
- }
-
- else if (VG_CLO_STREQ(arg, "--stacks=yes"))
- clo_stacks = True;
- else if (VG_CLO_STREQ(arg, "--stacks=no"))
- clo_stacks = False;
-
- else if (VG_CLO_STREQN(8, arg, "--depth=")) {
- clo_depth = (Int)VG_(atoll)(&arg[8]);
- if (clo_depth < 1) clo_depth = 1;
- if (clo_depth >= MAX_DEPTH) clo_depth = MAX_DEPTH;
- }
+ else VG_NUM_CLO ("--heap-admin", clo_heap_admin)
+ else VG_BNUM_CLO("--depth", clo_depth, 1, MAX_DEPTH)
else if (VG_CLO_STREQN(11, arg, "--alloc-fn=")) {
alloc_fns[n_alloc_fns] = & arg[11];
@@ -331,7 +312,7 @@
else
return VG_(replacement_malloc_process_cmd_line_option)(arg);
-
+
return True;
}