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