aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/crypto
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2006-10-24 08:46:17 +0000
committerMartin Willi <martin@strongswan.org>2006-10-24 08:46:17 +0000
commit55bbff11ec96f74b27afc36dd8ca3e34ff425b40 (patch)
tree9d0ff1aad70e01718405a8da314d22a86b072947 /src/libstrongswan/crypto
parent5c4cc9a4e328d86867959dec0e082f7e4f098a6e (diff)
downloadstrongswan-55bbff11ec96f74b27afc36dd8ca3e34ff425b40.tar.bz2
strongswan-55bbff11ec96f74b27afc36dd8ca3e34ff425b40.tar.xz
linked list cleanups
added list methods invoke(), destroy_offset(), destroy_function() simplified list destruction when destroying its items
Diffstat (limited to 'src/libstrongswan/crypto')
-rwxr-xr-xsrc/libstrongswan/crypto/crl.c22
-rwxr-xr-xsrc/libstrongswan/crypto/x509.c17
2 files changed, 8 insertions, 31 deletions
diff --git a/src/libstrongswan/crypto/crl.c b/src/libstrongswan/crypto/crl.c
index b2c24b80b..f1c21c74b 100755
--- a/src/libstrongswan/crypto/crl.c
+++ b/src/libstrongswan/crypto/crl.c
@@ -411,24 +411,10 @@ static void get_status(const private_crl_t *this, certinfo_t *certinfo)
*/
static void destroy(private_crl_t *this)
{
- revokedCert_t *revokedCert;
- identification_t *id;
-
- while (this->revokedCertificates->remove_last(this->revokedCertificates, (void**)&revokedCert) == SUCCESS)
- {
- free(revokedCert);
- }
- this->revokedCertificates->destroy(this->revokedCertificates);
-
- while (this->crlDistributionPoints->remove_last(this->crlDistributionPoints, (void**)&id) == SUCCESS)
- {
- id->destroy(id);
- }
- this->crlDistributionPoints->destroy(this->crlDistributionPoints);
-
- if (this->issuer)
- this->issuer->destroy(this->issuer);
-
+ this->revokedCertificates->destroy_function(this->revokedCertificates, free);
+ this->crlDistributionPoints->destroy_offset(this->crlDistributionPoints,
+ offsetof(identification_t, destroy));
+ DESTROY_IF(this->issuer);
free(this->certificateList.ptr);
free(this);
}
diff --git a/src/libstrongswan/crypto/x509.c b/src/libstrongswan/crypto/x509.c
index 4c5e014c8..9f59a0ee4 100755
--- a/src/libstrongswan/crypto/x509.c
+++ b/src/libstrongswan/crypto/x509.c
@@ -1188,19 +1188,10 @@ static void __attribute__ ((constructor))print_register()
*/
static void destroy(private_x509_t *this)
{
- identification_t *id;
- while (this->subjectAltNames->remove_last(this->subjectAltNames, (void**)&id) == SUCCESS)
- {
- id->destroy(id);
- }
- this->subjectAltNames->destroy(this->subjectAltNames);
-
- while (this->crlDistributionPoints->remove_last(this->crlDistributionPoints, (void**)&id) == SUCCESS)
- {
- id->destroy(id);
- }
- this->crlDistributionPoints->destroy(this->crlDistributionPoints);
-
+ this->subjectAltNames->destroy_offset(this->subjectAltNames,
+ offsetof(identification_t, destroy));
+ this->crlDistributionPoints->destroy_offset(this->crlDistributionPoints,
+ offsetof(identification_t, destroy));
DESTROY_IF(this->issuer);
DESTROY_IF(this->subject);
DESTROY_IF(this->public_key);