Thu, 20 Feb 2003 12:21:10 +0000
my own PDF routines to replace Panda.
eric@59 | 1 | #include <stdarg.h> |
eric@59 | 2 | #include <stdio.h> |
eric@59 | 3 | #include <stdlib.h> |
eric@59 | 4 | #include <string.h> |
eric@59 | 5 | |
eric@60 | 6 | #include "pdf.h" |
eric@60 | 7 | #include "pdf_util.h" |
eric@59 | 8 | |
eric@59 | 9 | |
eric@59 | 10 | void pdf_fatal (char *fmt, ...) |
eric@59 | 11 | { |
eric@59 | 12 | va_list ap; |
eric@59 | 13 | |
eric@59 | 14 | va_start (ap, fmt); |
eric@59 | 15 | vfprintf (stderr, fmt, ap); |
eric@59 | 16 | va_end (ap); |
eric@59 | 17 | |
eric@59 | 18 | exit (2); |
eric@59 | 19 | } |
eric@59 | 20 | |
eric@59 | 21 | |
eric@59 | 22 | void *pdf_calloc (long int size) |
eric@59 | 23 | { |
eric@59 | 24 | void *m = calloc (1, size); |
eric@59 | 25 | if (! m) |
eric@59 | 26 | pdf_fatal ("failed to allocate memory\n"); |
eric@59 | 27 | return (m); |
eric@59 | 28 | } |
eric@59 | 29 | |
eric@59 | 30 | |
eric@59 | 31 | char *pdf_strdup (char *s) |
eric@59 | 32 | { |
eric@59 | 33 | unsigned long len = strlen (s); |
eric@59 | 34 | char *s2 = pdf_calloc (len + 1); |
eric@59 | 35 | strcpy (s2, s); |
eric@59 | 36 | return (s2); |
eric@59 | 37 | } |