Handle allocation failures when instantiating documents
This commit is contained in:
parent
9d0835edbf
commit
1543a6c7b0
12 changed files with 255 additions and 31 deletions
|
|
@ -7,9 +7,16 @@
|
|||
#include "runtime/document.h"
|
||||
|
||||
TSDocument *ts_document_make() {
|
||||
TSDocument *document = ts_calloc(1, sizeof(TSDocument));
|
||||
document->parser = ts_parser_make();
|
||||
return document;
|
||||
TSDocument *self = ts_calloc(1, sizeof(TSDocument));
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
if (!ts_parser_init(&self->parser)) {
|
||||
ts_free(self);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void ts_document_free(TSDocument *self) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue