Changeset: d2540ed83105 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d2540ed83105
Modified Files:
gdk/gdk_tm.c
Branch: Aug2011
Log Message:
TMsubcommit: use GDKmalloc instead of alloca
Given that this function seems rarely used, we can easily pay the
overhead of malloc in this case to avoid using alloca for a variable
sized buffer (=SSP). Probably, a fixed size limit would work fine here,
but the input BAT theoretically could be very large.
diffs (31 lines):
diff --git a/gdk/gdk_tm.c b/gdk/gdk_tm.c
--- a/gdk/gdk_tm.c
+++ b/gdk/gdk_tm.c
@@ -190,10 +190,15 @@
TMsubcommit(BAT *b)
{
int cnt = 1;
- bat *subcommit = (bat *) alloca((BATcount(b) + 1) * sizeof(bat));
+ int ret = -1;
+ bat *subcommit;
BUN p, q;
BATiter bi = bat_iterator(b);
+ subcommit = (bat *) GDKmalloc((BATcount(b) + 1) * sizeof(bat));
+ if (subcommit == NULL)
+ return -1;
+
subcommit[0] = 0; /* BBP artifact: slot 0 in the array will be
ignored */
/* collect the list and save the new bats outside any locking */
BATloop(b, p, q) {
@@ -205,7 +210,9 @@
subcommit[cnt++] = bid;
}
- return TMsubcommit_list(subcommit, cnt);
+ ret = TMsubcommit_list(subcommit, cnt);
+ GDKfree(subcommit);
+ return ret;
}
/*
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list