Reduce memory usage

This commit is contained in:
Job Snijders
2021-08-20 01:58:38 +00:00
parent fb29cd54e1
commit 6c8c6cfec1
2 changed files with 9 additions and 13 deletions

View File

@@ -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

View File

@@ -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;
}
@@ -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);
}
}
}