1616#include <stdarg.h>
1717#include <stdio.h>
1818#include <stdlib.h>
19+ #include <string.h>
1920
2021#if _WIN32
2122#include <winsock2.h>
@@ -218,7 +219,8 @@ void test_excerpt_spz ( sphinx_client * client )
218219
219220void test_persist_work ( sphinx_client * client )
220221{
221- char * docs [] = { NULL };
222+ const char * docs [] = { NULL };
223+ char * docs0 ;
222224 const char words [] = "that is" ;
223225 const char * index = "test1" ;
224226 const char filler [] = " no need to worry about " ;
@@ -229,13 +231,14 @@ void test_persist_work ( sphinx_client * client )
229231
230232 // should be in sync with sphinxclient.c MAX_PACKET_LEN
231233 i = 8 * 1024 * 1024 + 50 ;
232- docs [ 0 ] = malloc ( i );
233- if ( !docs [ 0 ] )
234+ docs0 = malloc ( i );
235+ if ( !docs0 )
234236 die ( "malloc failed at test_persist_work" );
237+ docs [0 ] = docs0 ;
235238
236- memcpy ( docs [ 0 ] , words , sizeof (words )- 1 );
237- doc = docs [ 0 ] + sizeof (words )- 1 ;
238- while ( ( doc + sizeof (filler ) )< docs [ 0 ] + i )
239+ memcpy ( docs0 , words , sizeof (words )- 1 );
240+ doc = docs0 + sizeof (words )- 1 ;
241+ while ( ( doc + sizeof (filler ) )< docs0 + i )
239242 {
240243 memcpy ( doc , filler , sizeof (filler )- 1 );
241244 doc += sizeof (filler )- 1 ;
@@ -264,7 +267,7 @@ void test_persist_work ( sphinx_client * client )
264267 opts .html_strip_mode = "none" ;
265268 opts .query_mode = SPH_TRUE ;
266269
267- * ( docs [ 0 ] + sizeof (words )+ 100 ) = '\0' ;
270+ * ( docs0 + sizeof (words )+ 100 ) = '\0' ;
268271 }
269272
270273 printf ( "n=%d,\t" , i );
0 commit comments