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 );
60 fprintf( stderr, "%s:", input_file_name );
62 fprintf( stderr, "%d:", current_line );
65 vfprintf( stderr, msg, valist );
70 void fatal_perror( const char *msg, ... )
73 va_start( valist, msg );
76 fprintf( stderr, "%s:", input_file_name );
78 fprintf( stderr, "%d:", current_line );
81 vfprintf( stderr, msg, valist );
87 void warning( const char *msg, ... )
90 va_start( valist, msg );
93 fprintf( stderr, "%s:", input_file_name );
95 fprintf( stderr, "%d:", current_line );
98 fprintf( stderr, "warning: " );
99 vfprintf( stderr, msg, valist );
103 /* dump a byte stream into the assembly code */
104 void dump_bytes( FILE *outfile, const unsigned char *data, int len, const char *label )
108 fprintf( outfile, "\nstatic unsigned char %s[] = \n{", label );
110 for (i = 0; i < len; i++)
112 if (!(i & 0x0f)) fprintf( outfile, "\n " );
113 fprintf( outfile, "%d", *data++ );
114 if (i < len - 1) fprintf( outfile, ", " );
116 fprintf( outfile, "\n};\n" );