summaryrefslogtreecommitdiff
path: root/lib/resource.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-05-01 15:10:53 +0200
committerMaria Matejka <mq@ucw.cz>2023-05-06 10:50:31 +0200
commit7d8e54105713ee29c03c9aea108c3a6880836dcd (patch)
tree4bd9465ca912cba2f64df05c0bc06ba35f401a25 /lib/resource.h
parentb21909c6ee9dee131a9177a003c6d97cfb6fe1e0 (diff)
Linpool state save and restore refactoring
Diffstat (limited to 'lib/resource.h')
-rw-r--r--lib/resource.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/resource.h b/lib/resource.h
index 06af4289..abcf46fa 100644
--- a/lib/resource.h
+++ b/lib/resource.h
@@ -92,7 +92,6 @@ typedef struct linpool linpool;
typedef struct lp_state {
void *current, *large;
- byte *ptr;
uint total_large;
} lp_state;
@@ -101,9 +100,12 @@ void *lp_alloc(linpool *, unsigned size); /* Aligned */
void *lp_allocu(linpool *, unsigned size); /* Unaligned */
void *lp_allocz(linpool *, unsigned size); /* With clear */
void lp_flush(linpool *); /* Free everything, but leave linpool */
-void lp_save(linpool *m, lp_state *p); /* Save state */
+lp_state *lp_save(linpool *m); /* Save state */
void lp_restore(linpool *m, lp_state *p); /* Restore state */
+#define LP_SAVED(m) for (struct lp_state *_lp_state = lp_save(m); _lp_state; lp_restore(m, _lp_state), _lp_state = NULL)
+#define TMP_SAVED LP_SAVED(tmp_linpool)
+
struct tmp_resources {
pool *pool, *parent;
linpool *lp;