X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=3rdparty%2Flibe2ap%2Fasn_SEQUENCE_OF.c;fp=3rdparty%2Flibe2ap%2Fasn_SEQUENCE_OF.c;h=ec952fc99936ab1464d76ac75821fc19e47995cb;hb=ff8dccd02d76eebfccc0b509ce0b42a2c1760e12;hp=0000000000000000000000000000000000000000;hpb=f1d0eb6a82e11f14f60e3636d526299ced0173ea;p=ric-plt%2Fsubmgr.git diff --git a/3rdparty/libe2ap/asn_SEQUENCE_OF.c b/3rdparty/libe2ap/asn_SEQUENCE_OF.c new file mode 100644 index 0000000..ec952fc --- /dev/null +++ b/3rdparty/libe2ap/asn_SEQUENCE_OF.c @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include + +typedef A_SEQUENCE_OF(void) asn_sequence; + +void +asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) { + asn_sequence *as = (asn_sequence *)asn_sequence_of_x; + + if(as) { + void *ptr; + int n; + + if(number < 0 || number >= as->count) + return; /* Nothing to delete */ + + if(_do_free && as->free) { + ptr = as->array[number]; + } else { + ptr = 0; + } + + /* + * Shift all elements to the left to hide the gap. + */ + --as->count; + for(n = number; n < as->count; n++) + as->array[n] = as->array[n+1]; + + /* + * Invoke the third-party function only when the state + * of the parent structure is consistent. + */ + if(ptr) as->free(ptr); + } +} +