Added free_sync_msg, so that adapter can purge sync queue keysync
authorEdouard Tisserant
Tue, 27 Sep 2016 21:51:55 +0200
branchkeysync
changeset 1203c463238a1942
parent 1195 53f8859f476b
child 1204 e0859bbaf844
Added free_sync_msg, so that adapter can purge sync queue
src/sync.h
src/sync_impl.c
     1.1 --- a/src/sync.h	Mon Sep 26 16:55:23 2016 +0200
     1.2 +++ b/src/sync.h	Tue Sep 27 21:51:55 2016 +0200
     1.3 @@ -148,6 +148,12 @@
     1.4          void *management
     1.5      );
     1.6  
     1.7 +// free_sync_msg() - free sync_msg_t struct when not passed to do_sync_protocol  
     1.8 +//
     1.9 +//  parameters:
    1.10 +//      sync_msg (in)            pointer to sync_msg_t struct to free
    1.11 +
    1.12 +DYNAMIC_API void free_sync_msg(sync_msg_t *sync_msg);
    1.13  
    1.14  // decode_sync_msg() - decode sync message from PER into XER
    1.15  //
     2.1 --- a/src/sync_impl.c	Mon Sep 26 16:55:23 2016 +0200
     2.2 +++ b/src/sync_impl.c	Tue Sep 27 21:51:55 2016 +0200
     2.3 @@ -104,6 +104,32 @@
     2.4      return status;
     2.5  }
     2.6  
     2.7 +DYNAMIC_API void free_sync_msg(sync_msg_t *sync_msg)
     2.8 +{
     2.9 +    assert(sync_msg);
    2.10 +    if (!(sync_msg))
    2.11 +        return;
    2.12 +
    2.13 +    if(sync_msg->is_a_message){
    2.14 +        DeviceGroup_Protocol_t *msg = sync_msg->u.message;
    2.15 +        assert(msg);
    2.16 +        if (!(msg))
    2.17 +            return;
    2.18 +
    2.19 +        ASN_STRUCT_FREE(asn_DEF_DeviceGroup_Protocol, msg);
    2.20 +    }
    2.21 +    else{
    2.22 +        Identity partner = NULL;
    2.23 +        partner = sync_msg->u.event.partner;
    2.24 +        if(partner != NULL)
    2.25 +            free_identity(partner);
    2.26 +    }
    2.27 +
    2.28 +    free(sync_msg);
    2.29 +
    2.30 +    return;
    2.31 +}
    2.32 +
    2.33  // from sync.c
    2.34  int call_inject_sync_msg(PEP_SESSION session, void *msg);
    2.35