Files
openairinterface5g/common/utils/alg/find.c
T
Robert Schmidt 8107939f08 Change OAI license to CSSL v1.0 (and others)
- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
  scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly

For automated changes based on OAI PL v1.1:

    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
    perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml

The rest (cmake, files with missing license, cmake) manually.
2026-03-27 16:36:37 +01:00

32 lines
847 B
C

/*
* SPDX-License-Identifier: MIT
*
* Copyright (c) 2022 Mikel Irazabal
*/
#include "find.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
elm_arr_t find_if_arr_it(seq_arr_t* arr, void* start_it, void* end_it, void* value, bool (*f)(const void*, const void*))
{
assert(arr != NULL);
while (start_it != end_it) {
if (f(value, start_it))
return (elm_arr_t){.found = true, .it = start_it};
start_it = seq_arr_next(arr, start_it);
}
// If I trusted the average developer I should return it=start_it, but I don't.
return (elm_arr_t){.found = false, .it = NULL};
}
elm_arr_t find_if(seq_arr_t* arr, void* value, bool (*f)(const void*, const void*))
{
assert(arr != NULL);
void* start_it = seq_arr_front(arr);
void* end_it = seq_arr_end(arr);
return find_if_arr_it(arr, start_it, end_it, value, f);
}