fix the DB_scope in pgf_read_ngf

This commit is contained in:
krangelov
2021-08-08 16:29:51 +02:00
parent 8d1cc22622
commit f70e1b8772

View File

@@ -103,11 +103,11 @@ PgfPGF *pgf_read_ngf(const char *fpath, PgfExn* err)
try { try {
pgf = new PgfPGF(fpath, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); pgf = new PgfPGF(fpath, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if (DB::get_root<PgfPGFRoot>() == 0) { {
is_new = true;
DB_scope scope(pgf, WRITER_SCOPE); DB_scope scope(pgf, WRITER_SCOPE);
if (DB::get_root<PgfPGFRoot>() == 0) {
is_new = true;
ref<PgfPGFRoot> root = DB::malloc<PgfPGFRoot>(); ref<PgfPGFRoot> root = DB::malloc<PgfPGFRoot>();
root->major_version = 2; root->major_version = 2;
root->minor_version = 0; root->minor_version = 0;
@@ -117,6 +117,8 @@ PgfPGF *pgf_read_ngf(const char *fpath, PgfExn* err)
root->abstract.aflags = 0; root->abstract.aflags = 0;
root->abstract.funs = 0; root->abstract.funs = 0;
root->abstract.cats = 0; root->abstract.cats = 0;
DB::set_root<PgfPGFRoot>(root);
}
} }
return pgf; return pgf;