Skip to content

Commit d922c1f

Browse files
committed
Allocate buckets dynamically to reduce stack usage in msd_D_*_adaptive()
We're allocating a large number of vector data structures on the stack especially in the case of the adaptive algorithms. This is known to cause problems if the runtime stack size is limited. Allocate the memory dynamically to avoid this.
1 parent 970aaba commit d922c1f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/msd_dyn_vector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ void msd_D_##name(unsigned char** strings, size_t n) \
183183
ROUTINE_REGISTER_SINGLECORE(msd_D_##name, "msd_D_"#name) \
184184
void msd_D_##name##_adaptive(unsigned char** strings, size_t n) \
185185
{ \
186-
vec<unsigned char*> buckets[0x10000]; \
186+
vec<unsigned char*>* buckets = new vec<unsigned char*>[0x10000]; \
187187
msd_D_adaptive(strings, n, 0, buckets); \
188+
delete [] buckets; \
188189
} \
189190
ROUTINE_REGISTER_SINGLECORE(msd_D_##name##_adaptive, "msd_D_"#name"_adaptive")
190191

0 commit comments

Comments
 (0)