The goal is to solve confusion of the "All rights reserved" for licensing
code under an open-source license.
The phrase "All rights reserved" comes from a historical convention that
required this phrase for the copyright protection to apply. This convention
is no longer relevant.
However, even though the phrase has no meaning in establishing the copyright
it has not lost meaning in terms of licensing.
This change makes it so code under the Blender Foundation copyright does
not use "all rights reserved". This is also how the GPL license itself
states how to apply it to the source code:
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software ...
This change does not change copyright notice in cases when the copyright
is dual (BF and an author), or just an author of the code. It also does
mot change copyright which is inherited from NaN Holding BV as it needs
some further investigation about what is the proper way to handle it.
107 lines
1.9 KiB
C
107 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2013 Blender Foundation */
|
|
|
|
/** \file
|
|
* \ingroup bli
|
|
*
|
|
* Utility functions for sorting common types.
|
|
*/
|
|
|
|
#include "BLI_sort_utils.h" /* own include */
|
|
|
|
struct SortAnyByFloat {
|
|
float sort_value;
|
|
};
|
|
|
|
struct SortAnyByInt {
|
|
int sort_value;
|
|
};
|
|
|
|
struct SortAnyByPtr {
|
|
const void *sort_value;
|
|
};
|
|
|
|
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
|
|
{
|
|
const struct SortAnyByFloat *a = a_;
|
|
const struct SortAnyByFloat *b = b_;
|
|
if (a->sort_value > b->sort_value) {
|
|
return 1;
|
|
}
|
|
if (a->sort_value < b->sort_value) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
|
|
{
|
|
const struct SortAnyByFloat *a = a_;
|
|
const struct SortAnyByFloat *b = b_;
|
|
if (a->sort_value < b->sort_value) {
|
|
return 1;
|
|
}
|
|
if (a->sort_value > b->sort_value) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
|
|
{
|
|
const struct SortAnyByInt *a = a_;
|
|
const struct SortAnyByInt *b = b_;
|
|
if (a->sort_value > b->sort_value) {
|
|
return 1;
|
|
}
|
|
if (a->sort_value < b->sort_value) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
|
|
{
|
|
const struct SortAnyByInt *a = a_;
|
|
const struct SortAnyByInt *b = b_;
|
|
if (a->sort_value < b->sort_value) {
|
|
return 1;
|
|
}
|
|
if (a->sort_value > b->sort_value) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
|
|
{
|
|
const struct SortAnyByPtr *a = a_;
|
|
const struct SortAnyByPtr *b = b_;
|
|
if (a->sort_value > b->sort_value) {
|
|
return 1;
|
|
}
|
|
if (a->sort_value < b->sort_value) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
|
|
{
|
|
const struct SortAnyByPtr *a = a_;
|
|
const struct SortAnyByPtr *b = b_;
|
|
if (a->sort_value < b->sort_value) {
|
|
return 1;
|
|
}
|
|
if (a->sort_value > b->sort_value) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|