From f5fddc4dbbe67d984b514fdd9cdfbd6e5be6c489 Mon Sep 17 00:00:00 2001 From: Alan C Francis Date: Sun, 31 Dec 2023 18:11:21 +0000 Subject: [PATCH] add a way to insert lines --- containers/linearray.c | 16 +++++++++++++--- containers/linearray.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/containers/linearray.c b/containers/linearray.c index ba1e503..3577572 100644 --- a/containers/linearray.c +++ b/containers/linearray.c @@ -5,6 +5,7 @@ #include "configmodel.h" // ----------------------------- +#define InsertToArray(ElemType, array, pos, value) do { *((ElemType *)InsertArrayElements(array, pos, 1)) = value;} while(0); // ----------------------------- @@ -21,13 +22,22 @@ VOID LineArrayAppend(LineArray array, LINEPTR value) AppendToArray(LINEPTR, array, value); } +VOID LineArrayInsert(LineArray array, LINEPTR value, ULONG pos) +{ + AppendToArray(LINEPTR, array, value); +// InsertToArray(LINEPTR, array, pos, value); +} + VOID LineArrayFree(LineArray array, BOOL freeLines) { - if( freeLines ) + if( array != NULL ) { - ArrayForEach(LINEPTR, aLine, array, LineFree(aLine);); + if( freeLines ) + { + ArrayForEach(LINEPTR, aLine, array, LineFree(aLine);); + } + DeleteArray(array); } - DeleteArray(array); } LINEPTR* LineArrayValues(LineArray array) diff --git a/containers/linearray.h b/containers/linearray.h index fea74f4..23ea8ad 100644 --- a/containers/linearray.h +++ b/containers/linearray.h @@ -8,6 +8,7 @@ LineArray LineArrayNew(VOID); VOID LineArrayAppend(LineArray array, LINEPTR value); +VOID LineArrayInsert(LineArray array, LINEPTR value, ULONG pos); VOID LineArrayFree(LineArray array, BOOL freeLines); LINEPTR* LineArrayValues(LineArray array);