1 /* small utility functions for winebuild */
12 void *xmalloc (size_t size)
16 res = malloc (size ? size : 1);
19 fprintf (stderr, "Virtual memory exhausted.\n");
25 void *xrealloc (void *ptr, size_t size)
27 void *res = realloc (ptr, size);
30 fprintf (stderr, "Virtual memory exhausted.\n");
36 char *xstrdup( const char *str )
38 char *res = strdup( str );
41 fprintf (stderr, "Virtual memory exhausted.\n");
47 char *strupper(char *s)
50 for (p = s; *p; p++) *p = toupper(*p);
54 void fatal_error( const char *msg, ... )
57 va_start( valist, msg );
58 if (input_file_name && current_line)
59 fprintf( stderr, "%s:%d: ", input_file_name, current_line );
60 vfprintf( stderr, msg, valist );
65 /* dump a byte stream into the assembly code */
66 void dump_bytes( FILE *outfile, const unsigned char *data, int len, const char *label )
70 fprintf( outfile, "\nstatic unsigned char %s[] = \n{", label );
72 for (i = 0; i < len; i++)
74 if (!(i & 0x0f)) fprintf( outfile, "\n " );
75 fprintf( outfile, "%d", *data++ );
76 if (i < len - 1) fprintf( outfile, ", " );
78 fprintf( outfile, "\n};\n" );