5 #define BIGSTRING 1048576
6 #define STRINGSPACE ( BIGSTRING * 20 )
14 char *strjoin(const char *first,...) {
16 if ( heap.base == 0 ) {
17 heap.base = (char*) malloc( STRINGSPACE );
18 heap.current = heap.base;
19 heap.end = heap.base + STRINGSPACE;
21 char *start = heap.current;
22 const char *p = first;
23 size_t size = strlen( first ) + 1;
24 va_start( ap, first );
25 while ( ( p = va_arg( ap, const char* ) ) ) {
29 if ( size > BIGSTRING ) {
30 start = (char*) malloc( size );
32 if ( heap.current + size > heap.end ) {
33 heap.current = heap.base;
38 char *current = start;
39 strcpy( current, first );
40 current += strlen( first );
41 va_start( ap, first );
42 while ( ( p = va_arg( ap, const char* ) ) ) {
44 current += strlen( p );
51 void strfree(char *p) {
52 if ( p < heap.base || p >= heap.end ) {