1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/pdf_util.c Thu Feb 20 12:16:00 2003 +0000 1.3 @@ -0,0 +1,37 @@ 1.4 +#include <stdarg.h> 1.5 +#include <stdio.h> 1.6 +#include <stdlib.h> 1.7 +#include <string.h> 1.8 + 1.9 +#include "libpdf.h" 1.10 +#include "libpdf_util.h" 1.11 + 1.12 + 1.13 +void pdf_fatal (char *fmt, ...) 1.14 +{ 1.15 + va_list ap; 1.16 + 1.17 + va_start (ap, fmt); 1.18 + vfprintf (stderr, fmt, ap); 1.19 + va_end (ap); 1.20 + 1.21 + exit (2); 1.22 +} 1.23 + 1.24 + 1.25 +void *pdf_calloc (long int size) 1.26 +{ 1.27 + void *m = calloc (1, size); 1.28 + if (! m) 1.29 + pdf_fatal ("failed to allocate memory\n"); 1.30 + return (m); 1.31 +} 1.32 + 1.33 + 1.34 +char *pdf_strdup (char *s) 1.35 +{ 1.36 + unsigned long len = strlen (s); 1.37 + char *s2 = pdf_calloc (len + 1); 1.38 + strcpy (s2, s); 1.39 + return (s2); 1.40 +}