MCPcopy Create free account
hub / github.com/creatale/node-dv / arrayFindEachSequence

Function arrayFindEachSequence

deps/leptonica/src/utils2.c:972–1005  ·  view source on GitHub ↗

! * \brief arrayFindEachSequence() * * \param[in] data byte array * \param[in] datalen length of data, in bytes * \param[in] sequence subarray of bytes to find in data * \param[in] seqlen length of sequence, in bytes * \return dna of offsets where the sequence is found, or NULL if * none are found or on error * * * Notes: * (1) The byte arrays %da

Source from the content-addressed store, hash-verified

970 * </pre>
971 */
972L_DNA *
973arrayFindEachSequence(const l_uint8 *data,
974 size_t datalen,
975 const l_uint8 *sequence,
976 size_t seqlen)
977{
978l_int32 start, offset, realoffset, found;
979L_DNA *da;
980
981 PROCNAME("arrayFindEachSequence");
982
983 if (!data || !sequence)
984 return (L_DNA *)ERROR_PTR("data & sequence not both defined",
985 procName, NULL);
986
987 da = l_dnaCreate(0);
988 start = 0;
989 while (1) {
990 arrayFindSequence(data + start, datalen - start, sequence, seqlen,
991 &offset, &found);
992 if (found == FALSE)
993 break;
994
995 realoffset = start + offset;
996 l_dnaAddNumber(da, realoffset);
997 start = realoffset + seqlen;
998 if (start >= datalen)
999 break;
1000 }
1001
1002 if (l_dnaGetCount(da) == 0)
1003 l_dnaDestroy(&da);
1004 return da;
1005}
1006
1007
1008/*!

Callers 2

substituteObjectNumbersFunction · 0.85
l_byteaFindEachSequenceFunction · 0.85

Calls 5

l_dnaCreateFunction · 0.85
arrayFindSequenceFunction · 0.85
l_dnaAddNumberFunction · 0.85
l_dnaGetCountFunction · 0.85
l_dnaDestroyFunction · 0.85

Tested by

no test coverage detected