@@ -90,13 +90,18 @@ void DivSufSort::reset()
9090 memset (&_bucketB[0 ], 0 , sizeof (int ) * 65536 );
9191}
9292
93- void DivSufSort::computeSuffixArray (const byte input[], int sa[], int length)
93+ bool DivSufSort::computeSuffixArray (const byte input[], int sa[], int length)
9494{
9595 _buffer = reinterpret_cast <const uint8*>(&input[0 ]);
9696 _sa = sa;
9797 reset ();
9898 const int m = sortTypeBstar (_bucketA, _bucketB, length);
99+
100+ if (m < 0 )
101+ return false ;
102+
99103 constructSuffixArray (_bucketA, _bucketB, length, m);
104+ return true ;
100105}
101106
102107void DivSufSort::constructSuffixArray (int bucketA[], int bucketB[], int n, int m)
@@ -163,16 +168,20 @@ void DivSufSort::constructSuffixArray(int bucketA[], int bucketB[], int n, int m
163168 }
164169}
165170
166- int DivSufSort::computeBWT (const byte input[], byte output[], int bwt[], int length, int indexes[], int idxCount)
171+ bool DivSufSort::computeBWT (const byte input[], byte output[], int bwt[], int length, int indexes[], int idxCount)
167172{
168173 _buffer = reinterpret_cast <const uint8*>(&input[0 ]);
169174 _sa = bwt;
170175 reset ();
171176 const int m = sortTypeBstar (_bucketA, _bucketB, length);
177+
178+ if (m < 0 )
179+ return false ;
180+
172181 const int pIdx = constructBWT (_bucketA, _bucketB, length, m, indexes, idxCount);
173182
174183 if (pIdx < 0 )
175- return - 1 ;
184+ return false ;
176185
177186 output[0 ] = input[length - 1 ];
178187
@@ -182,7 +191,7 @@ int DivSufSort::computeBWT(const byte input[], byte output[], int bwt[], int len
182191 for (int i = pIdx + 1 ; i < length; i++)
183192 output[i] = byte (bwt[i]);
184193
185- return pIdx + 1 ;
194+ return true ;
186195}
187196
188197int DivSufSort::constructBWT (int bucketA[], int bucketB[], int n, int m, int indexes[], int idxCount)
0 commit comments