add a way to insert lines

main
Alan Francis 1 year ago
parent 0d2fd66b6a
commit f5fddc4dbb
  1. 10
      containers/linearray.c
  2. 1
      containers/linearray.h

@ -5,6 +5,7 @@
#include "configmodel.h" #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); 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) VOID LineArrayFree(LineArray array, BOOL freeLines)
{ {
if( array != NULL )
{
if( freeLines ) if( freeLines )
{ {
ArrayForEach(LINEPTR, aLine, array, LineFree(aLine);); ArrayForEach(LINEPTR, aLine, array, LineFree(aLine););
} }
DeleteArray(array); DeleteArray(array);
}
} }
LINEPTR* LineArrayValues(LineArray array) LINEPTR* LineArrayValues(LineArray array)

@ -8,6 +8,7 @@
LineArray LineArrayNew(VOID); LineArray LineArrayNew(VOID);
VOID LineArrayAppend(LineArray array, LINEPTR value); VOID LineArrayAppend(LineArray array, LINEPTR value);
VOID LineArrayInsert(LineArray array, LINEPTR value, ULONG pos);
VOID LineArrayFree(LineArray array, BOOL freeLines); VOID LineArrayFree(LineArray array, BOOL freeLines);
LINEPTR* LineArrayValues(LineArray array); LINEPTR* LineArrayValues(LineArray array);

Loading…
Cancel
Save