summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authorhunt <hunt>2006-11-06 19:04:04 +0000
committerhunt <hunt>2006-11-06 19:04:04 +0000
commit3a02f9bf9b9ccf502aa51b80f18be556b493a579 (patch)
tree37bf28d295d5ed0b61620e0091decb1293d31d9e /translate.cxx
parent9f6cfc6aa98476877444bf86e35c13bec9ae7080 (diff)
downloadsystemtap-steved-3a02f9bf9b9ccf502aa51b80f18be556b493a579.tar.gz
systemtap-steved-3a02f9bf9b9ccf502aa51b80f18be556b493a579.tar.xz
systemtap-steved-3a02f9bf9b9ccf502aa51b80f18be556b493a579.zip
2006-11-06 Martin Hunt <hunt@redhat.com>
* translate.cxx (var::init): Check for errors when allocating arrays of stats, as well as other arrays.
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx25
1 files changed, 9 insertions, 16 deletions
diff --git a/translate.cxx b/translate.cxx
index 14d58ef2..a7406387 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -623,41 +623,34 @@ struct mapvar
string mtype = is_parallel() ? "pmap" : "map";
string prefix = qname() + " = _stp_" + mtype + "_new_" + keysym() + " (MAXMAPENTRIES" ;
+ // Check for errors during allocation.
+ string suffix = "if (" + qname () + " == NULL) rc = -ENOMEM;";
+
if (type() == pe_stats)
{
switch (sdecl().type)
{
case statistic_decl::none:
- return (prefix
- + ", HIST_NONE);");
+ prefix = prefix + ", HIST_NONE";
break;
case statistic_decl::linear:
// FIXME: check for "reasonable" values in linear stats
- return (prefix
- + ", HIST_LINEAR"
- + ", " + stringify(sdecl().linear_low)
- + ", " + stringify(sdecl().linear_high)
- + ", " + stringify(sdecl().linear_step)
- + ");");
+ prefix = prefix + ", HIST_LINEAR"
+ + ", " + stringify(sdecl().linear_low)
+ + ", " + stringify(sdecl().linear_high)
+ + ", " + stringify(sdecl().linear_step);
break;
case statistic_decl::logarithmic:
if (sdecl().logarithmic_buckets > 64)
throw semantic_error("cannot support > 64 logarithmic buckets");
- return (prefix
- + ", HIST_LOG"
- + ", " + stringify(sdecl().logarithmic_buckets)
- + ");");
+ prefix = prefix + ", HIST_LOG" + ", " + stringify(sdecl().logarithmic_buckets);
break;
}
}
prefix = prefix + "); ";
-
- // Check for errors during allocation.
- string suffix = "if (" + qname () + " == NULL) rc = -ENOMEM;";
-
return (prefix + suffix);
}