1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-24 22:13:15 +00:00
gnss-sdr/src/core/libs/supl/asn-supl/asn_SEQUENCE_OF.c
Carles Fernandez 4d0d263280
Make the software package compliant with the REUSE Specification v3.0 (see https://reuse.software/spec/)
Update license headers to SPDX format (see https://spdx.org/)
Add license to all files
Add CI job in GitHub Actions to ensure compliance
2020-02-08 01:20:02 +01:00

52 lines
1.3 KiB
C

/*-
* SPDX-FileCopyrightText: (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* SPDX-License-Identifier: BSD-1-Clause
*/
#include <asn_SEQUENCE_OF.h>
#include <asn_internal.h>
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);
}
}
}