Rephrase ts_subtree_array_copy to avoid conspicuous null case
This avoids a false positive error from the clang static analyzer, which doesn't understand the invariants of the Array type.
This commit is contained in:
parent
75cf95bddc
commit
b29c5dbf15
2 changed files with 10 additions and 13 deletions
|
|
@ -67,20 +67,17 @@ bool ts_external_scanner_state_eq(const ExternalScannerState *a, const ExternalS
|
|||
|
||||
// SubtreeArray
|
||||
|
||||
bool ts_subtree_array_copy(SubtreeArray self, SubtreeArray *dest) {
|
||||
const Subtree **contents = NULL;
|
||||
if (self.capacity > 0) {
|
||||
contents = ts_calloc(self.capacity, sizeof(Subtree *));
|
||||
memcpy(contents, self.contents, self.size * sizeof(Subtree *));
|
||||
for (uint32_t i = 0; i < self.size; i++) {
|
||||
ts_subtree_retain(contents[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ts_subtree_array_copy(SubtreeArray self, SubtreeArray *dest) {
|
||||
dest->size = self.size;
|
||||
dest->capacity = self.capacity;
|
||||
dest->contents = contents;
|
||||
return true;
|
||||
dest->contents = self.contents;
|
||||
if (self.capacity > 0) {
|
||||
dest->contents = ts_calloc(self.capacity, sizeof(Subtree *));
|
||||
memcpy(dest->contents, self.contents, self.size * sizeof(Subtree *));
|
||||
for (uint32_t i = 0; i < self.size; i++) {
|
||||
ts_subtree_retain(dest->contents[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ts_subtree_array_delete(SubtreePool *pool, SubtreeArray *self) {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ typedef struct {
|
|||
void ts_external_scanner_state_init(ExternalScannerState *, const char *, unsigned);
|
||||
const char *ts_external_scanner_state_data(const ExternalScannerState *);
|
||||
|
||||
bool ts_subtree_array_copy(SubtreeArray, SubtreeArray *);
|
||||
void ts_subtree_array_copy(SubtreeArray, SubtreeArray *);
|
||||
void ts_subtree_array_delete(SubtreePool *, SubtreeArray *);
|
||||
SubtreeArray ts_subtree_array_remove_trailing_extras(SubtreeArray *);
|
||||
void ts_subtree_array_reverse(SubtreeArray *);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue