@@@ fltfmt mess
[mLib] / test / tvec-timeout.c
index f1b0b0c..c22724d 100644 (file)
@@ -36,6 +36,8 @@
 #include <unistd.h>
 
 #include "tvec.h"
+#include "tvec-timeout.h"
+#include "tvec-types.h"
 
 /*----- Main code ---------------------------------------------------------*/
 
@@ -72,8 +74,8 @@ void tvec_timeoutsetup(struct tvec_state *tv, const struct tvec_env *env,
 
   reset(tc);
 
-  tc->subctx = 0;
-  if (subenv && subenv->ctxsz) tc->subctx = xmalloc(subenv->ctxsz);
+  if (subenv && subenv->ctxsz) tc->subctx = x_alloc(tv->a, subenv->ctxsz);
+  else tc->subctx = 0;
   if (subenv && subenv->setup) subenv->setup(tv, subenv, tc, tc->subctx);
 }
 
@@ -243,6 +245,7 @@ void tvec_timeoutteardown(struct tvec_state *tv, void *ctx)
 
   /* Just call the subsidiary environment. */
   if (subenv && subenv->teardown) subenv->teardown(tv, tc->subctx);
+  x_free(tv->a, tc->subctx);
 }
 
 /*----- That's all, folks -------------------------------------------------*/