5 #define BIGSTRING 1048576
6 #define STRINGSPACE ( BIGSTRING * 20 )
14 static inline void strinitialize() {
15 if ( heap.base == 0 ) {
16 heap.base = (char*) malloc( STRINGSPACE );
17 heap.current = heap.base;
18 heap.end = heap.base + STRINGSPACE;
22 extern char *stralloc(int size) {
24 if ( heap.current + size >= heap.end ) {
25 heap.current = heap.base;
27 char *start = heap.current;
32 char *strjoin(const char *first,...) {
35 char *start = heap.current;
36 const char *p = first;
37 size_t size = strlen( first ) + 1;
38 va_start( ap, first );
39 while ( ( p = va_arg( ap, const char* ) ) ) {
43 if ( size > BIGSTRING ) {
44 start = (char*) malloc( size );
46 if ( heap.current + size >= heap.end ) {
47 heap.current = heap.base;
52 char *current = start;
53 strcpy( current, first );
54 current += strlen( first );
55 va_start( ap, first );
56 while ( ( p = va_arg( ap, const char* ) ) ) {
58 current += strlen( p );
65 void strfree(char *p) {
66 if ( p < heap.base || p >= heap.end ) {