Skip to content

Commit

Permalink
Reduce memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
job committed Aug 20, 2021
1 parent fb29cd5 commit 6c8c6cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
9 changes: 5 additions & 4 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
1.3 (2021-XX-XX)
- Change versioning from X.Y.Z to Y.Z
- the repository file hierachy has been reorganized (compat/ include/)
- man page has been extended
- large portions of code have been reformatted to adhere to OpenBSD's source
- The repository file hierachy has been reorganized (compat/ include/)
- Man page has been extended
- Large portions of code have been reformatted to adhere to OpenBSD's source
file style guide to improve readability.
- refactor: replace two-dimensional array for ASN storage with Red-Black tree
- Refactor: replace two-dimensional array for ASN storage with Red-Black tree
- Reduced memory usage

0.0.9 (2021-08-18)
- Fix various memory errors
Expand Down
13 changes: 4 additions & 9 deletions expander.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ bgpq_expander_invalidate_asn(struct bgpq_expander *b, const char *q)
sx_report(SX_ERROR, "overflow: %s\n", q);
return;
}
if (asn >= 4294967295) {
if (asn == 0 || asn >= 4294967295) {
sx_report(SX_ERROR, "out of range: %s\n", q);
return;
}
Expand All @@ -456,15 +456,10 @@ bgpq_expander_invalidate_asn(struct bgpq_expander *b, const char *q)
}

find.asn = asn;
res = RB_FIND(asn_tree, &b->asnlist, &find);
if (res == NULL)
return;

if (RB_REMOVE(asn_tree, &b->asnlist, res) == NULL) {
sx_report(SX_ERROR, "failed to remove: %lu", asn);
return;
if ((res = RB_FIND(asn_tree, &b->asnlist, &find)) == NULL) {
RB_REMOVE(asn_tree, &b->asnlist, res);
free(res);
}

}
}

Expand Down

0 comments on commit 6c8c6cf

Please sign in to comment.