Skip to content

mdz_ansi_alg_insert

Maksym Dzyubenko edited this page Oct 6, 2024 · 4 revisions

Insert pcItems into pcData from nLeftPos position. pcData and pcItems cannot overlap. New size is returned in pnDataSize.
Size and capacity - do not include 0-terminator; thus size and capacity of empty string with no free space are 0

enum mdz_error mdz_ansi_alg_insert(
  char* pcData,
  size_t* pnDataSize,
  size_t nDataCapacity,
  size_t nLeftPos,
  const char* pcItems,
  size_t nCount);

Parameter Description
pcData pointer to string. It should end with 0-terminator and have enough capacity for insertion of pcItems
pnDataSize pointer to current Size. Size is 0 for empty string. If insertion succeeded, new size is returned here
nDataCapacity maximal capacity of pcData buffer. nDataCapacity does not include 0-terminator byte, thus pcData buffer should be at least 1 byte bigger than nDataCapacity
nLeftPos 0-based position to insert. If nLeftPos == Size items are appended. nLeftPos > Size is not allowed
pcItems items to insert. Cannot be NULL
nCount number of items to insert. Cannot be 0
Return Description
MDZ_ERROR_LICENSE license is not initialized using mdz_ansi_alg_init() or invalid
MDZ_ERROR_DATA pcData is NULL
MDZ_ERROR_SIZE pnDataSize is NULL
MDZ_ERROR_BIG_SIZE Size > Capacity
MDZ_ERROR_CAPACITY nDataCapacity is 0 (no space for insertion) or SIZE_MAX (no space for 0-terminator)
MDZ_ERROR_TERMINATOR there is no 0-terminator in the end of pcData ([Size] position)
MDZ_ERROR_ITEMS pcItems is NULL
MDZ_ERROR_ZERO_COUNT nCount is 0
MDZ_ERROR_BIG_LEFT nLeftPos > Size
MDZ_ERROR_BIG_COUNT Size + nCount > nDataCapacity
MDZ_ERROR_OVERLAP pcData + pcItems memory - overlap with pcItems
MDZ_ERROR_NONE function succeeded, new size is written in pnDataSize
mdz_ansi_alg API Reference is generated using mdzApiRefGenerator.