summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/levcomp.lpp
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-07 07:51:48 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-07 07:51:48 +0000
commitb58fbcfafc44bc2810863a3722bee2e6a8f7d22d (patch)
tree22a1199ad8ca845bfad04590d9dc5e9891ae8960 /crawl-ref/source/util/levcomp.lpp
parentcf61c793d3d3783b2b5a39a8cf01b857806411b2 (diff)
downloadcrawl-ref-b58fbcfafc44bc2810863a3722bee2e6a8f7d22d.tar.gz
crawl-ref-b58fbcfafc44bc2810863a3722bee2e6a8f7d22d.zip
*Breaks save compatibility* - changed monster flags to long, added "god" field for future fun.
dungeon.cc cleanup and rework to support floating vaults. Updated levcomp to support the float orientation. coord_def now has a constructor. USE_RIVERS and USE_NEW_UNRANDS are no longer conditional. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@585 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util/levcomp.lpp')
-rw-r--r--crawl-ref/source/util/levcomp.lpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/crawl-ref/source/util/levcomp.lpp b/crawl-ref/source/util/levcomp.lpp
index 69ad33ee23..59118eee7e 100644
--- a/crawl-ref/source/util/levcomp.lpp
+++ b/crawl-ref/source/util/levcomp.lpp
@@ -8,13 +8,32 @@
#include "AppHdr.h"
#include "levcomp.tab.h"
#include <cstring>
+#include <queue>
static bool alloced = false;
+std::queue<const char *> free_queue;
+
+static void flush_free_queue(int max_allowed)
+{
+ while (free_queue.size() > max_allowed)
+ {
+ const char *s = free_queue.front();
+ free((void *) s);
+ free_queue.pop();
+ }
+}
+
+static void add_to_queue(const char *s)
+{
+ free_queue.push(s);
+ flush_free_queue(20);
+}
+
static void clean()
{
if (yylval.text && alloced)
- free( (void*) yylval.text);
+ add_to_queue(yylval.text);
yylval.text = NULL;
alloced = false;
}
@@ -83,7 +102,7 @@ EXIT_MSG: { BEGIN(ARGUMENT); return EXIT_MSG; }
MONSTERS return MONSTERS;
ENDMONSTERS return ENDMONSTERS;
-<KEYWORDS>[A-Za-z_0-9\-]+ {
+<KEYWORDS>[A-Za-z_0-9\-]+ {
settext();
return STRING;
}
@@ -114,6 +133,7 @@ northeast return NORTHEAST;
northwest return NORTHWEST;
southeast return SOUTHEAST;
southwest return SOUTHWEST;
+float return FLOAT;
- return DASH;
, return COMMA;
@@ -151,5 +171,6 @@ southwest return SOUTHWEST;
int yywrap()
{
clean();
+ flush_free_queue(0);
return 1;
}