free(identity) -> free_identity(identity)
authorRoker <roker@pep-project.org>
Mon, 19 Dec 2016 08:36:53 +0100
changeset 1496eacf1934b6cc
parent 1495 1397da6f9084
child 1497 5c110c844ff5
child 1499 e841d7759915
child 1500 6cc35643fed0
child 1501 a47ea9fdbd81
free(identity) -> free_identity(identity)
test/trustwords_test.cc
     1.1 --- a/test/trustwords_test.cc	Mon Dec 19 02:42:41 2016 +0100
     1.2 +++ b/test/trustwords_test.cc	Mon Dec 19 08:36:53 2016 +0100
     1.3 @@ -1,22 +1,23 @@
     1.4  #include <iostream>
     1.5  #include <string>
     1.6 -#include <assert.h>
     1.7 +#include <cassert>
     1.8  #include "pEpEngine.h"
     1.9  #include "message_api.h"
    1.10  
    1.11  using namespace std;
    1.12  
    1.13 +
    1.14  int main() {
    1.15      cout << "\n*** get_trustwords test ***\n\n";
    1.16  
    1.17 -    PEP_SESSION session;
    1.18 +    PEP_SESSION session = nullptr;
    1.19      
    1.20      cout << "calling init()\n";
    1.21 -    PEP_STATUS status1 = init(&session);   
    1.22 +    PEP_STATUS status1 = init(&session);
    1.23      assert(status1 == PEP_STATUS_OK);
    1.24      assert(session);
    1.25      cout << "init() completed.\n";
    1.26 -        
    1.27 +    
    1.28      pEp_identity* identity1  = new_identity(
    1.29          "leon.schumacher@digitalekho.com",
    1.30          "8BD08954C74D830EEFFB5DEB2682A17F7C87F73D",
    1.31 @@ -31,12 +32,12 @@
    1.32      
    1.33      string fingerprint1 = identity1->fpr;
    1.34      string fingerprint2 = identity2->fpr;
    1.35 -    char* words1;
    1.36 -    char* words2;
    1.37 -    char* full_wordlist;
    1.38 -    size_t wsize1;
    1.39 -    size_t wsize2;
    1.40 -    size_t wsize_full;
    1.41 +    char* words1 = nullptr;
    1.42 +    char* words2 = nullptr;
    1.43 +    char* full_wordlist = nullptr;
    1.44 +    size_t wsize1 = 0;
    1.45 +    size_t wsize2 = 0;
    1.46 +    size_t wsize_full = 0;
    1.47      
    1.48      cout << "\nTest 1: fpr1 > fpr2, short" << endl;
    1.49      
    1.50 @@ -57,8 +58,11 @@
    1.51      
    1.52      
    1.53      pEp_free(words1);
    1.54 +    words1 = nullptr;
    1.55      pEp_free(words2);
    1.56 +    words2 = nullptr;
    1.57      pEp_free(full_wordlist);
    1.58 +    full_wordlist = nullptr;
    1.59  
    1.60      cout << "\nTest 2: fpr1 == fpr1, short" << endl;
    1.61      
    1.62 @@ -73,7 +77,9 @@
    1.63      cout << full_wordlist << "\n";
    1.64  
    1.65      pEp_free(words1);
    1.66 +    words1 = nullptr;
    1.67      pEp_free(full_wordlist);
    1.68 +    full_wordlist = nullptr;
    1.69  
    1.70      cout << "\nTest 3: fpr1 < fpr2, long" << endl;
    1.71      
    1.72 @@ -93,9 +99,11 @@
    1.73      cout << full_wordlist << "\n";
    1.74      
    1.75      pEp_free(words1);
    1.76 +    words1 = nullptr;
    1.77      pEp_free(words2);
    1.78 +    words2 = nullptr;
    1.79      pEp_free(full_wordlist);
    1.80 -    
    1.81 +    full_wordlist = nullptr;
    1.82      
    1.83      cout << "\nTest 4: fpr1 < fpr2, leading zeros (fpr1 has more), long" << endl;
    1.84      
    1.85 @@ -137,8 +145,11 @@
    1.86      cout << full_wordlist << "\n";
    1.87  
    1.88      pEp_free(words1);
    1.89 +    words1 = nullptr;
    1.90      pEp_free(words2);
    1.91 +    words2 = nullptr;
    1.92      pEp_free(full_wordlist);
    1.93 +    full_wordlist = nullptr;
    1.94  
    1.95      cout << "\nTest 5: fpr1 > fpr2, leading zeros (same number), interior digit difference, short" << endl;
    1.96      
    1.97 @@ -158,8 +169,11 @@
    1.98      cout << full_wordlist << "\n";
    1.99      
   1.100      pEp_free(words1);
   1.101 +    words1 = nullptr;
   1.102      pEp_free(words2);
   1.103 +    words2 = nullptr;
   1.104      pEp_free(full_wordlist);
   1.105 +    full_wordlist = nullptr;
   1.106  
   1.107      cout << "\nTest 6: fpr2 is too short" << endl;
   1.108      
   1.109 @@ -188,13 +202,13 @@
   1.110      cout << "Illegal digit value correctly recognised." << "\n";
   1.111      
   1.112      
   1.113 -    free(identity1);
   1.114 -    free(identity2);
   1.115 -    free(identity3);
   1.116 -    free(identity4);
   1.117 -    free(identity5);
   1.118 -    free(identity6);
   1.119 -    free(identity7);
   1.120 +    free_identity(identity1);
   1.121 +    free_identity(identity2);
   1.122 +    free_identity(identity3);
   1.123 +    free_identity(identity4);
   1.124 +    free_identity(identity5);
   1.125 +    free_identity(identity6);
   1.126 +    free_identity(identity7);
   1.127      
   1.128      cout << "calling release()\n";
   1.129      release(session);