8#ifndef ELLIPSIS_SARRAY_H
9#define ELLIPSIS_SARRAY_H 1
33#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__)
34#define STRINGIFY_(...) #__VA_ARGS__
36#define ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR, ...) \
38 static char const contract_format_ ## COUNT[] = \
39 __FILE__ ":" STRINGIFY(__LINE__) ": violation of " CTYPE " `" CSTR "`" __VA_OPT__(", ") __VA_ARGS__ "\n";\
41 ? fputs(contract_format_ ## COUNT, stderr) \
45#define ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
48 : (ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR __VA_OPT__(,) __VA_ARGS__) \
53#define ELLIPSIS_TO_VOIDS(...) ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__))))
55#define ELLIPSIS_TEST_ICE(...) (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr)
57#define ELLIPSIS_CONTRACT_ICE_OR_TRUE(...) \
59 ELLIPSIS_TEST_ICE(__VA_ARGS__), \
60 ellipsis‿contracts‿is_ice*: (__VA_ARGS__), \
63#define ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR, ...) \
65 static_assert(ELLIPSIS_CONTRACT_ICE_OR_TRUE(COND), \
66 "compile time violation of " CTYPE " " CSTR \
67 __VA_OPT__(", ") __VA_ARGS__ );\
70#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
74 ELLIPSIS_TEST_ICE(COND), \
75 ellipsis‿contracts‿is_ice*: ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR __VA_OPT__(,) __VA_ARGS__), \
76 default: ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE __VA_OPT__(,) __VA_ARGS__));\
141#ifndef DOXYGEN_SPECIAL
155 [[deprecated(
"use const member length instead")]]
157#ifndef DOXYGEN_SPECIAL
177#define ELLIPSIS_SARRAY_OVERLAY(N) \
180 size_t const length;\
181 size_t const padding;\
182 unsigned const :(offsetof(ellipsis‿sarray, array)-2*sizeof(size_t));\
183 ellipsis‿sarray‿base array[N];\
188#define ELLIPSIS_SARRAY_STATIC(N, ...) \
190 static const ELLIPSIS_SARRAY_OVERLAY( \
191 sizeof((ellipsis‿sarray‿base[]){__VA_ARGS__ }) \
192 /sizeof(ellipsis‿sarray‿base)) \
195 .array = {__VA_ARGS__ }, \
196 };&__LOC_ID_1_1;})->fa)
218#if __clang__ && (__clang_major__ < 30)
219#define ELLIPSIS_SARRAY_LITERAL_LOCAL(N, ...) ELLIPSIS_SARRAY_STATIC(N, __VA_ARGS__)
221#define ELLIPSIS_SARRAY_LITERAL_LOCAL(N, ...) \
222 ((static const ELLIPSIS_SARRAY_OVERLAY( \
223 sizeof((ellipsis‿sarray‿base[]){__VA_ARGS__ }) \
224 /sizeof(ellipsis‿sarray‿base))) \
227 .array = {__VA_ARGS__ }, \
231#define ELLIPSIS_SARRAY_LITERAL_GLOBAL(N, ...) \
232 ((const ELLIPSIS_SARRAY_OVERLAY( \
233 sizeof((ellipsis‿sarray‿base[]){__VA_ARGS__ }) \
234 /sizeof(ellipsis‿sarray‿base))) \
237 .array = {__VA_ARGS__ }, \
240#define ELLIPSIS_SARRAY_LITERAL ELLIPSIS_SARRAY_LITERAL_LOCAL
270 *__LOC_ID_0_1= *__LOC_ID_0_2;
271 *__LOC_ID_0_2=
nullptr;
273 *__LOC_ID_0_1=
nullptr;
290 *__LOC_ID_0_3= *__LOC_ID_0_4;
291 *__LOC_ID_0_4=
nullptr;
293 *__LOC_ID_0_3=
nullptr;
309 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
312 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
313 [[__maybe_unused__]]
register bool defer_return_flag =
false;
316 goto DEFER_END_ID_1_2;
320 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
321 unsigned (*DEFER_LOC_ID_1_1)[DEFER_LOC_ID_0_2] = {};
324 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
325 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
326 {
ELLIPSIS_CONTRACT(1, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"out of memory when growing an FA array");}
334 defer_return_flag =
true;
341[[__maybe_unused__]] DEFER_END_ID_1_2:;
342 return DEFER_LOC_ID_0_1;
364 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
367 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
368 [[__maybe_unused__]]
register bool defer_return_flag =
false;
371 goto DEFER_END_ID_1_4;
375 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
376 unsigned (*DEFER_LOC_ID_1_2)[DEFER_LOC_ID_0_2] = {};
379 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
380 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
381 {
ELLIPSIS_CONTRACT(2, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"out of memory when creating a one element FA array");}
386 do {
ELLIPSIS_CONTRACT(3, !s || (s->length < s->capacity) || (s->capacity < SIZE_MAX), abort,
true,
"¬s ∨ (s→length < s→capacity) ∨ (s→capacity < SIZE_MAX)",
"assertion",
"FA array is a its limits");}
while (
false);
390 defer_return_flag =
true;
397[[__maybe_unused__]] DEFER_END_ID_1_4:;
398 return DEFER_LOC_ID_0_1;
412 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
415 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
416 [[__maybe_unused__]]
register bool defer_return_flag =
false;
419 goto DEFER_END_ID_1_6;
423 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
424 unsigned (*DEFER_LOC_ID_1_3)[DEFER_LOC_ID_0_2] = {};
427 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
428 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
429 {
ELLIPSIS_CONTRACT(4, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"out of memory when concatenating two FA arrays");}
434 do {
ELLIPSIS_CONTRACT(5, s && t, abort,
true,
"s ∧ t",
"assertion",
"argument FA arrays for concatenation must not be null");}
while (
false);
435 do {
ELLIPSIS_CONTRACT(6, s->length <= (SIZE_MAX - t->length), abort,
true,
"s→length ≤ (SIZE_MAX − t→length)",
"assertion",
"concatenation of FA would be too long");}
while (
false);
439 defer_return_flag =
true;
446[[__maybe_unused__]] DEFER_END_ID_1_6:;
447 return DEFER_LOC_ID_0_1;
482 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
485 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
486 [[__maybe_unused__]]
register bool defer_return_flag =
false;
489 goto DEFER_END_ID_1_8;
493 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
494 unsigned (*DEFER_LOC_ID_1_4)[DEFER_LOC_ID_0_2] = {};
497 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
498 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
499 {
ELLIPSIS_CONTRACT(7, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"out of memory when growing an FA array");}
507 defer_return_flag =
true;
514[[__maybe_unused__]] DEFER_END_ID_1_8:;
515 return DEFER_LOC_ID_0_1;
537 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
540 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
541 [[__maybe_unused__]]
register bool defer_return_flag =
false;
544 goto DEFER_END_ID_1_10;
548 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
549 unsigned (*DEFER_LOC_ID_1_5)[DEFER_LOC_ID_0_2] = {};
552 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
553 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
554 {
ELLIPSIS_CONTRACT(8, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"out of memory when growing an FA array");}
559 do {
ELLIPSIS_CONTRACT(9, !s || ((
bool)((s)->
capacity)), abort,
true,
"¬s ∨ ((bool)((s)→capacity))",
"assertion",
"flexible array object must be in allocated storage to be growable");}
while (
false);
560 do {
ELLIPSIS_CONTRACT(10, !s || s->length < SIZE_MAX, abort,
true,
"¬s ∨ s→length < SIZE_MAX",
"assertion",
"FA array is a its limits");}
while (
false);
564 defer_return_flag =
true;
571[[__maybe_unused__]] DEFER_END_ID_1_10:;
572 return DEFER_LOC_ID_0_1;
596 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
599 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
600 [[__maybe_unused__]]
register bool defer_return_flag =
false;
603 goto DEFER_END_ID_1_12;
607 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
608 unsigned (*DEFER_LOC_ID_1_6)[DEFER_LOC_ID_0_2] = {};
611 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
612 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
613 {
ELLIPSIS_CONTRACT(11, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"out of memory when shrinking an FA array");}
618 do {
ELLIPSIS_CONTRACT(12, s, abort,
true,
"s",
"assertion",
"can only shrink existing array");}
while (
false);
619 do {
ELLIPSIS_CONTRACT(13, ((
bool)((s)->
capacity)), abort,
true,
"((bool)((s)→capacity))",
"assertion",
"flexible array object must be in allocated storage to be shrinkable");}
while (
false);
620 do {
ELLIPSIS_CONTRACT(14, length <= s->
length, abort,
true,
"length ≤ s→length",
"assertion",
"can\'t shrink array to make it longer");}
while (
false);
624 defer_return_flag =
true;
631[[__maybe_unused__]] DEFER_END_ID_1_12:;
632 return DEFER_LOC_ID_0_1;
647 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
650 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
651 [[__maybe_unused__]]
register bool defer_return_flag =
false;
654 goto DEFER_END_ID_1_14;
657 do {
ELLIPSIS_CONTRACT(15, s, abort,
true,
"s",
"assertion",
"substring from non-existing string");}
while (
false);
658 do {
ELLIPSIS_CONTRACT(16, pos < s->
length, abort,
true,
"pos < s→length",
"assertion",
"start of substring is out of bounds");}
while (
false);
660 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
661 unsigned (*DEFER_LOC_ID_1_7)[DEFER_LOC_ID_0_2] = {};
664 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
665 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
666 {
ELLIPSIS_CONTRACT(17, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"out of memory when growing an FA array");}
674 defer_return_flag =
true;
681[[__maybe_unused__]] DEFER_END_ID_1_14:;
682 return DEFER_LOC_ID_0_1;
700 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
703 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
704 [[__maybe_unused__]]
register bool defer_return_flag =
false;
707 goto DEFER_END_ID_1_16;
710 do {
ELLIPSIS_CONTRACT(18, s, abort,
true,
"s",
"assertion",
"copy of non-existing string");}
while (
false);
712 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
713 unsigned (*DEFER_LOC_ID_1_8)[DEFER_LOC_ID_0_2] = {};
716 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
717 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
718 {
ELLIPSIS_CONTRACT(19, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"copy operation failed");}
726 defer_return_flag =
true;
733[[__maybe_unused__]] DEFER_END_ID_1_16:;
734 return DEFER_LOC_ID_0_1;
748 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
751 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
752 [[__maybe_unused__]]
register bool defer_return_flag =
false;
755 goto DEFER_END_ID_1_18;
759 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
760 unsigned (*DEFER_LOC_ID_1_9)[DEFER_LOC_ID_0_2] = {};
763 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
764 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
765 {
ELLIPSIS_CONTRACT(20, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"out of memory when growing an FA array");}
773 defer_return_flag =
true;
780[[__maybe_unused__]] DEFER_END_ID_1_18:;
781 return DEFER_LOC_ID_0_1;
803 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
806 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
807 [[__maybe_unused__]]
register bool defer_return_flag =
false;
810 goto DEFER_END_ID_1_20;
814 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
815 unsigned (*DEFER_LOC_ID_1_10)[DEFER_LOC_ID_0_2] = {};
818 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
819 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
820 {
ELLIPSIS_CONTRACT(21, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"out of memory when creating a one element FA array");}
825 do {
ELLIPSIS_CONTRACT(22, !s || (s->length < s->capacity) || (s->capacity < SIZE_MAX), unreachable,
false,
"¬s ∨ (s→length < s→capacity) ∨ (s→capacity < SIZE_MAX)",
"assumption",
"FA array is a its limits");}
while (
false);
829 defer_return_flag =
true;
836[[__maybe_unused__]] DEFER_END_ID_1_20:;
837 return DEFER_LOC_ID_0_1;
851 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
854 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
855 [[__maybe_unused__]]
register bool defer_return_flag =
false;
858 goto DEFER_END_ID_1_22;
862 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
863 unsigned (*DEFER_LOC_ID_1_11)[DEFER_LOC_ID_0_2] = {};
866 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
867 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
868 {
ELLIPSIS_CONTRACT(23, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"out of memory when concatenating two FA arrays");}
873 do {
ELLIPSIS_CONTRACT(24, s && t, unreachable,
false,
"s ∧ t",
"assumption",
"argument FA arrays for concatenation must not be null");}
while (
false);
874 do {
ELLIPSIS_CONTRACT(25, s->length <= (SIZE_MAX - t->length), unreachable,
false,
"s→length ≤ (SIZE_MAX − t→length)",
"assumption",
"concatenation of FA would be too long");}
while (
false);
878 defer_return_flag =
true;
885[[__maybe_unused__]] DEFER_END_ID_1_22:;
886 return DEFER_LOC_ID_0_1;
921 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
924 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
925 [[__maybe_unused__]]
register bool defer_return_flag =
false;
928 goto DEFER_END_ID_1_24;
932 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
933 unsigned (*DEFER_LOC_ID_1_12)[DEFER_LOC_ID_0_2] = {};
936 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
937 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
938 {
ELLIPSIS_CONTRACT(26, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"out of memory when growing an FA array");}
946 defer_return_flag =
true;
953[[__maybe_unused__]] DEFER_END_ID_1_24:;
954 return DEFER_LOC_ID_0_1;
976 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
979 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
980 [[__maybe_unused__]]
register bool defer_return_flag =
false;
983 goto DEFER_END_ID_1_26;
987 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
988 unsigned (*DEFER_LOC_ID_1_13)[DEFER_LOC_ID_0_2] = {};
991 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
992 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
993 {
ELLIPSIS_CONTRACT(27, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"out of memory when growing an FA array");}
998 do {
ELLIPSIS_CONTRACT(28, !s || ((
bool)((s)->
capacity)), unreachable,
false,
"¬s ∨ ((bool)((s)→capacity))",
"assumption",
"flexible array object must be in allocated storage to be growable");}
while (
false);
999 do {
ELLIPSIS_CONTRACT(29, !s || s->length < SIZE_MAX, unreachable,
false,
"¬s ∨ s→length < SIZE_MAX",
"assumption",
"FA array is a its limits");}
while (
false);
1003 defer_return_flag =
true;
1010[[__maybe_unused__]] DEFER_END_ID_1_26:;
1011 return DEFER_LOC_ID_0_1;
1035 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
1038 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
1039 [[__maybe_unused__]]
register bool defer_return_flag =
false;
1042 goto DEFER_END_ID_1_28;
1046 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
1047 unsigned (*DEFER_LOC_ID_1_14)[DEFER_LOC_ID_0_2] = {};
1050 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
1051 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
1052 {
ELLIPSIS_CONTRACT(30, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"out of memory when shrinking an FA array");}
1057 do {
ELLIPSIS_CONTRACT(31, s, unreachable,
false,
"s",
"assumption",
"can only shrink existing array");}
while (
false);
1058 do {
ELLIPSIS_CONTRACT(32, ((
bool)((s)->
capacity)), unreachable,
false,
"((bool)((s)→capacity))",
"assumption",
"flexible array object must be in allocated storage to be shrinkable");}
while (
false);
1059 do {
ELLIPSIS_CONTRACT(33, length <= s->
length, unreachable,
false,
"length ≤ s→length",
"assumption",
"can\'t shrink array to make it longer");}
while (
false);
1063 defer_return_flag =
true;
1070[[__maybe_unused__]] DEFER_END_ID_1_28:;
1071 return DEFER_LOC_ID_0_1;
1086 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
1089 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
1090 [[__maybe_unused__]]
register bool defer_return_flag =
false;
1093 goto DEFER_END_ID_1_30;
1096 do {
ELLIPSIS_CONTRACT(34, s, unreachable,
false,
"s",
"assumption",
"substring from non-existing string");}
while (
false);
1097 do {
ELLIPSIS_CONTRACT(35, pos < s->
length, unreachable,
false,
"pos < s→length",
"assumption",
"start of substring is out of bounds");}
while (
false);
1099 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
1100 unsigned (*DEFER_LOC_ID_1_15)[DEFER_LOC_ID_0_2] = {};
1103 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
1104 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
1105 {
ELLIPSIS_CONTRACT(36, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"out of memory when growing an FA array");}
1113 defer_return_flag =
true;
1120[[__maybe_unused__]] DEFER_END_ID_1_30:;
1121 return DEFER_LOC_ID_0_1;
1139 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
1142 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
1143 [[__maybe_unused__]]
register bool defer_return_flag =
false;
1146 goto DEFER_END_ID_1_32;
1149 do {
ELLIPSIS_CONTRACT(37, s, unreachable,
false,
"s",
"assumption",
"copy of non-existing string");}
while (
false);
1151 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
1152 unsigned (*DEFER_LOC_ID_1_16)[DEFER_LOC_ID_0_2] = {};
1155 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
1156 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
1157 {
ELLIPSIS_CONTRACT(38, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"copy operation failed");}
1165 defer_return_flag =
true;
1172[[__maybe_unused__]] DEFER_END_ID_1_32:;
1173 return DEFER_LOC_ID_0_1;
1205 memset(_ar, 0, _n*
sizeof(_ar[0]));
1219 return memcmp(_a, _b,
sizeof(_a[0]));
1247 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
1250 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
1251 [[__maybe_unused__]]
register bool defer_return_flag =
false;
1254 goto DEFER_END_ID_1_34;
1257 ELLIPSIS_CONTRACT(39, __LOC_ID_0_5, abort,
true,
"__LOC(0, 1)",
"precondition",
"copy of non-existing string");
1260 defer_return_flag =
true;
1267[[__maybe_unused__]] DEFER_END_ID_1_34:;
1268 return DEFER_LOC_ID_0_1;
1295 extern void (qsort)(
void*, size_t, size_t, int (*)(
const void*,
const void*));
1297 size_t rlen = p->
length - offs;
1298 if (rlen < len) len = rlen;
1315 extern void* (bsearch)(
void const*,
void const*,
size_t,
size_t,
int (*)(
const void*,
const void*));
1317 size_t rlen = p->
length - offs;
1318 if (rlen < len) len = rlen;
#define GNU_ATTR_COUNTED_BY(...)
Definition ellipsis-error.h:59
#define STDC_ATTR_NODISCARD(...)
Definition ellipsis-error.h:68
#define GNU_ATTR_STRICT_FLEX_ARRAY(...)
Definition ellipsis-error.h:54
#define GNU_ATTR_RETURNS_NONNULL
Definition ellipsis-error.h:34
struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice
Definition ellipsis-expression.c:24
ellipsis‿sarray * ellipsis‿sarray‿alloc‿_Inner(size_t len)
Definition ellipsis-sarray.c:147
ellipsis‿sarray * ellipsis‿sarray‿shrink‿_Inner(ellipsis‿sarray s[restrict static 1], size_t length)
Definition ellipsis-sarray.c:228
ellipsis‿sarray const * ellipsis‿sarray‿cpy_const‿_Inner(ellipsis‿sarray const *restrict s)
Definition ellipsis-sarray.c:257
ellipsis‿sarray * ellipsis‿sarray‿sub‿_Inner(ellipsis‿sarray const *s, size_t pos, size_t len)
Definition ellipsis-sarray.c:240
ellipsis‿sarray * ellipsis‿sarray‿append‿_Inner(ellipsis‿sarray *restrict s, s->array[0] c)
Definition ellipsis-sarray.c:159
ellipsis‿sarray * ellipsis‿sarray‿grow‿_Inner(ellipsis‿sarray *restrict s, size_t length)
Definition ellipsis-sarray.c:202
ellipsis‿sarray * ellipsis‿sarray‿concat_inplace‿_Inner(ellipsis‿sarray const *s0, ellipsis‿sarray const *t)
Definition ellipsis-sarray.c:183
ellipsis‿sarray * ellipsis‿sarray‿concat‿_Inner(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Definition ellipsis-sarray.c:168
thread_local bool volatile ellipsis‿contracts‿verbose‿dynamic
#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE,...)
Definition ellipsis-sarray.h:70
thread_local bool volatile ellipsis‿contracts‿proceed‿dynamic
thread_local bool volatile ellipsis‿contracts‿ignore‿dynamic
A structure with a flexible array member of base type ellipsis‿sarray‿base.
Definition ellipsis-sarray.h:140
int ellipsis‿sarray‿compare(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Compare two arrays lexicographically.
Definition ellipsis-sarray.c:119
ellipsis‿sarray * ellipsis‿sarray‿grow‿_Ctra(ellipsis‿sarray *restrict s, size_t length)
Grow the ellipsis‿sarray to (at least) the indicated amount of elements return a new one and delete t...
Definition ellipsis-sarray.h:974
ellipsis‿sarray * ellipsis‿sarray‿grow(ellipsis‿sarray *restrict s, size_t length)
Grow the ellipsis‿sarray to (at least) the indicated amount of elements return a new one and delete t...
Definition ellipsis-sarray.h:535
size_t const length
Current length of this instance.
Definition ellipsis-sarray.h:149
ellipsis‿sarray const * ellipsis‿sarray‿cpy_const(ellipsis‿sarray const *restrict s)
Copy or link to a const-qualified ellipsis‿sarray.
Definition ellipsis-sarray.h:698
ellipsis‿sarray * ellipsis‿sarray‿alloc‿_Ctra(size_t len)
Allocate a ellipsis‿sarray with elements as given by the parameter.
Definition ellipsis-sarray.h:746
ellipsis‿sarray * ellipsis‿sarray‿alloc‿_Insta(size_t len)
Allocate a ellipsis‿sarray with elements as given by the parameter.
Definition ellipsis-sarray.c:272
void ellipsis‿sarray‿move(ellipsis‿sarray *__LOC_ID_0_1[restrict static 1], ellipsis‿sarray **restrict __LOC_ID_0_2)
Move a ellipsis‿sarray pointed to by the second parameter to the one pointed to by the first.
Definition ellipsis-sarray.h:266
ellipsis‿sarray * ellipsis‿sarray‿grow‿_Insta(ellipsis‿sarray *restrict s, size_t length)
Grow the ellipsis‿sarray to (at least) the indicated amount of elements return a new one and delete t...
Definition ellipsis-sarray.c:456
void ellipsis‿sarray‿delete(ellipsis‿sarray const *)
Delete a ellipsis‿sarray pointed to by the parameter.
Definition ellipsis-sarray.c:615
ellipsis‿sarray * ellipsis‿sarray‿concat(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Concatenate two ellipsis‿sarray into a new one.
Definition ellipsis-sarray.h:410
ellipsis‿sarray‿base array[]
The current data array.
Definition ellipsis-sarray.h:174
ellipsis‿sarray * ellipsis‿sarray‿sub(ellipsis‿sarray const *restrict s, size_t pos, size_t len)
Allocate a ellipsis‿sarray with len elements and copy the data from *s at position pos onward.
Definition ellipsis-sarray.h:645
ellipsis‿sarray const * ellipsis‿sarray‿cpy_const‿_Ctra(ellipsis‿sarray const *restrict s)
Copy or link to a const-qualified ellipsis‿sarray.
Definition ellipsis-sarray.h:1137
size_t length_mod
Modifiable length of this instance.
Definition ellipsis-sarray.h:156
ellipsis‿sarray * ellipsis‿sarray‿concat_inplace(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Concatenate two ellipsis‿sarray into a new one and delete s.
Definition ellipsis-sarray.h:480
void ellipsis‿sarray‿base‿destroy(size_t _n, ellipsis‿sarray‿base _ar[static _n])
Destroy an element of type ellipsis‿sarray‿base.
Definition ellipsis-sarray.h:1204
ellipsis‿sarray‿base const * ellipsis‿sarray‿search(ellipsis‿sarray‿base const el[static 1], ellipsis‿sarray const *p, size_t offs, size_t len)
search for an element in a ellipsis‿sarray
Definition ellipsis-sarray.h:1314
int ellipsis‿sarray‿compareInternal(void const *A, void const *B)
Definition ellipsis-sarray.h:1275
ellipsis‿sarray * ellipsis‿sarray‿remove(ellipsis‿sarray s[restrict static 1], size_t)
Remove (at most) the indicated amount of elements from the ellipsis‿sarray return a new one and delet...
Definition ellipsis-sarray.c:108
ellipsis‿sarray * ellipsis‿sarray‿concat_inplace‿_Insta(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Concatenate two ellipsis‿sarray into a new one and delete s.
Definition ellipsis-sarray.c:412
ellipsis‿sarray * ellipsis‿sarray‿append‿_Ctra(ellipsis‿sarray *restrict s, ellipsis‿sarray‿base c)
Append a new element to a ellipsis‿sarray and return a new object.
Definition ellipsis-sarray.h:801
ellipsis‿sarray * ellipsis‿sarray‿concat‿_Insta(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Concatenate two ellipsis‿sarray into a new one.
Definition ellipsis-sarray.c:353
size_t ellipsis‿sarray‿base
Definition ellipsis-sarray.h:16
ellipsis‿sarray * ellipsis‿sarray‿append‿_Insta(ellipsis‿sarray *restrict s, ellipsis‿sarray‿base c)
Append a new element to a ellipsis‿sarray and return a new object.
Definition ellipsis-sarray.c:316
void ellipsis‿sarray‿sort(ellipsis‿sarray *p, size_t offs, size_t len)
sort a ellipsis‿sarray in place.
Definition ellipsis-sarray.h:1294
ellipsis‿sarray * ellipsis‿sarray‿cpy(ellipsis‿sarray const *restrict __LOC_ID_0_5)
Allocate a ellipsis‿sarray and copy the data to which the parameter points into it.
Definition ellipsis-sarray.h:1245
ellipsis‿sarray const * ellipsis‿sarray‿cpy_const‿_Insta(ellipsis‿sarray const *restrict s)
Copy or link to a const-qualified ellipsis‿sarray.
Definition ellipsis-sarray.c:586
ellipsis‿sarray * ellipsis‿sarray‿concat_inplace‿_Ctra(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Concatenate two ellipsis‿sarray into a new one and delete s.
Definition ellipsis-sarray.h:919
ellipsis‿sarray * ellipsis‿sarray‿append(ellipsis‿sarray *restrict s, ellipsis‿sarray‿base c)
Append a new element to a ellipsis‿sarray and return a new object.
Definition ellipsis-sarray.h:362
ellipsis‿sarray * ellipsis‿sarray‿shrink‿_Ctra(ellipsis‿sarray s[restrict static 1], size_t length)
Shrink the ellipsis‿sarray to exactly the indicated amount of elements return a new one and delete th...
Definition ellipsis-sarray.h:1033
int ellipsis‿sarray‿base‿compare(ellipsis‿sarray‿base const _a[static 1], ellipsis‿sarray‿base const _b[static 1])
Compare two elements of type ellipsis‿sarray‿base.
Definition ellipsis-sarray.h:1218
ellipsis‿sarray * ellipsis‿sarray‿concat‿_Ctra(ellipsis‿sarray const *s, ellipsis‿sarray const *t)
Concatenate two ellipsis‿sarray into a new one.
Definition ellipsis-sarray.h:849
size_t const capacity
Maximal length of this instance.
Definition ellipsis-sarray.h:166
ellipsis‿sarray * ellipsis‿sarray‿sub‿_Insta(ellipsis‿sarray const *restrict s, size_t pos, size_t len)
Allocate a ellipsis‿sarray with len elements and copy the data from *s at position pos onward.
Definition ellipsis-sarray.c:544
ellipsis‿sarray * ellipsis‿sarray‿alloc(size_t len)
Allocate a ellipsis‿sarray with elements as given by the parameter.
Definition ellipsis-sarray.h:307
ellipsis‿sarray * ellipsis‿sarray‿shrink(ellipsis‿sarray s[restrict static 1], size_t length)
Shrink the ellipsis‿sarray to exactly the indicated amount of elements return a new one and delete th...
Definition ellipsis-sarray.h:594
void ellipsis‿sarray‿cmove(ellipsis‿sarray const *__LOC_ID_0_3[restrict static 1], ellipsis‿sarray const **restrict __LOC_ID_0_4)
Move a ellipsis‿sarray const pointed to by the second parameter to the one pointed to by the first.
Definition ellipsis-sarray.h:286
ellipsis‿sarray * ellipsis‿sarray‿shrink‿_Insta(ellipsis‿sarray s[restrict static 1], size_t length)
Shrink the ellipsis‿sarray to exactly the indicated amount of elements return a new one and delete th...
Definition ellipsis-sarray.c:504
ellipsis‿sarray * ellipsis‿sarray‿sub‿_Ctra(ellipsis‿sarray const *restrict s, size_t pos, size_t len)
Allocate a ellipsis‿sarray with len elements and copy the data from *s at position pos onward.
Definition ellipsis-sarray.h:1084