+
+ /*
+ * We need a temporary buffer. If it is small, let's use stack.
+ * Otherwise, we malloc it, but we have to be careful, since we
+ * might be running inside a transaction and bwrite() could
+ * throw an exception.
+ *
+ * FIXME: This deserves a more systematic solution, the same
+ * problem is likely to happen at other places, too.
+ */
+ int bufsize = len + 1;
+ struct resource *res = NULL;
+ byte *extra_buffer = NULL;
+ if (bufsize <= 256)
+ buf = alloca(bufsize);
+ else if (rp_current())
+ buf = res_malloc(bufsize, &res);