comparison src/c/urweb.c @ 1084:8e240c007442

Don't relify in bigLibs; fix some memory bugs in transactionals
author Adam Chlipala <adamc@hcoop.net>
date Wed, 23 Dec 2009 14:27:12 -0500
parents 2eb585274501
children e81434513720
comparison
equal deleted inserted replaced
1083:2eb585274501 1084:8e240c007442
2849 for (i = 0; i < ctx->used_transactionals; ++i) 2849 for (i = 0; i < ctx->used_transactionals; ++i)
2850 if (ctx->transactionals[i].rollback != NULL) 2850 if (ctx->transactionals[i].rollback != NULL)
2851 ctx->transactionals[i].rollback(ctx->transactionals[i].data); 2851 ctx->transactionals[i].rollback(ctx->transactionals[i].data);
2852 2852
2853 for (i = 0; i < ctx->used_transactionals; ++i) 2853 for (i = 0; i < ctx->used_transactionals; ++i)
2854 ctx->transactionals[i].free(ctx->transactionals[i].data); 2854 if (ctx->transactionals[i].free)
2855 ctx->transactionals[i].free(ctx->transactionals[i].data);
2855 2856
2856 return uw_db_rollback(ctx); 2857 return uw_db_rollback(ctx);
2857 } 2858 }
2858 2859
2859 void uw_register_transactional(uw_context ctx, void *data, uw_callback commit, uw_callback rollback, 2860 void uw_register_transactional(uw_context ctx, void *data, uw_callback commit, uw_callback rollback,
2860 uw_callback free) { 2861 uw_callback free) {
2861 if (ctx->used_transactionals >= ctx->n_transactionals) { 2862 if (ctx->used_transactionals >= ctx->n_transactionals) {
2862 ctx->transactionals = realloc(ctx->transactionals, ctx->used_transactionals+1); 2863 ctx->transactionals = realloc(ctx->transactionals, sizeof(transactional) * (ctx->used_transactionals+1));
2863 ++ctx->n_transactionals; 2864 ++ctx->n_transactionals;
2864 } 2865 }
2865 2866
2866 ctx->transactionals[ctx->used_transactionals].data = data; 2867 ctx->transactionals[ctx->used_transactionals].data = data;
2867 ctx->transactionals[ctx->used_transactionals].commit = commit; 2868 ctx->transactionals[ctx->used_transactionals].commit = commit;