Mercurial > urweb
comparison src/c/urweb.c @ 1782:61c7eb1d3867
Support fancy expressions in module-level 'val' declarations
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Wed, 18 Jul 2012 17:29:13 -0400 |
parents | 22858505bb2d |
children | 69daa6d70299 |
comparison
equal
deleted
inserted
replaced
1781:25824a0e8bf1 | 1782:61c7eb1d3867 |
---|---|
463 uw_Basis_postBody postBody; | 463 uw_Basis_postBody postBody; |
464 uw_Basis_string queryString; | 464 uw_Basis_string queryString; |
465 | 465 |
466 unsigned nextId; | 466 unsigned nextId; |
467 | 467 |
468 int amInitializing; | |
469 | |
468 char error_message[ERROR_BUF_LEN]; | 470 char error_message[ERROR_BUF_LEN]; |
469 }; | 471 }; |
470 | 472 |
471 size_t uw_headers_max = SIZE_MAX; | 473 size_t uw_headers_max = SIZE_MAX; |
472 size_t uw_page_max = SIZE_MAX; | 474 size_t uw_page_max = SIZE_MAX; |
533 ctx->isPost = ctx->hasPostBody = 0; | 535 ctx->isPost = ctx->hasPostBody = 0; |
534 | 536 |
535 ctx->queryString = NULL; | 537 ctx->queryString = NULL; |
536 | 538 |
537 ctx->nextId = 0; | 539 ctx->nextId = 0; |
540 | |
541 ctx->amInitializing = 0; | |
538 | 542 |
539 return ctx; | 543 return ctx; |
540 } | 544 } |
541 | 545 |
542 size_t uw_inputs_max = SIZE_MAX; | 546 size_t uw_inputs_max = SIZE_MAX; |
611 ctx->cur_container = NULL; | 615 ctx->cur_container = NULL; |
612 ctx->used_transactionals = 0; | 616 ctx->used_transactionals = 0; |
613 ctx->script_header = ""; | 617 ctx->script_header = ""; |
614 ctx->queryString = NULL; | 618 ctx->queryString = NULL; |
615 ctx->nextId = 0; | 619 ctx->nextId = 0; |
620 ctx->amInitializing = 0; | |
616 } | 621 } |
617 | 622 |
618 void uw_reset_keep_request(uw_context ctx) { | 623 void uw_reset_keep_request(uw_context ctx) { |
619 uw_reset_keep_error_message(ctx); | 624 uw_reset_keep_error_message(ctx); |
620 ctx->error_message[0] = 0; | 625 ctx->error_message[0] = 0; |
1202 | 1207 |
1203 void uw_set_heap_front(uw_context ctx, char *fr) { | 1208 void uw_set_heap_front(uw_context ctx, char *fr) { |
1204 ctx->heap.front = fr; | 1209 ctx->heap.front = fr; |
1205 } | 1210 } |
1206 | 1211 |
1212 void uw_begin_initializing(uw_context ctx) { | |
1213 ctx->amInitializing = 1; | |
1214 } | |
1215 | |
1216 void uw_end_initializing(uw_context ctx) { | |
1217 ctx->amInitializing = 0; | |
1218 } | |
1219 | |
1207 void *uw_malloc(uw_context ctx, size_t len) { | 1220 void *uw_malloc(uw_context ctx, size_t len) { |
1208 void *result; | 1221 void *result; |
1209 | 1222 |
1210 uw_check_heap(ctx, len); | 1223 if (ctx->amInitializing) { |
1211 | 1224 result = malloc(len); |
1212 result = ctx->heap.front; | 1225 |
1213 ctx->heap.front += len; | 1226 if (result) |
1214 return result; | 1227 return result; |
1228 else | |
1229 uw_error(ctx, FATAL, "uw_malloc: malloc() returns 0"); | |
1230 } else { | |
1231 uw_check_heap(ctx, len); | |
1232 | |
1233 result = ctx->heap.front; | |
1234 ctx->heap.front += len; | |
1235 return result; | |
1236 } | |
1215 } | 1237 } |
1216 | 1238 |
1217 void uw_begin_region(uw_context ctx) { | 1239 void uw_begin_region(uw_context ctx) { |
1218 regions *r = (regions *) ctx->heap.front; | 1240 regions *r = (regions *) ctx->heap.front; |
1219 | 1241 |