Mon, 14 Dec 2009 15:44:55 +0000
update tags
1 /*
2 * tumble: build a PDF file from image files
3 *
4 * PDF routines
5 * $Id: pdf_util.c,v 1.6 2003/03/13 00:57:05 eric Exp $
6 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. Note that permission is
11 * not granted to redistribute this program under the terms of any
12 * other version of the General Public License.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
22 */
25 #include <stdarg.h>
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
32 #include "bitblt.h"
33 #include "pdf_util.h"
36 void pdf_fatal (char *fmt, ...)
37 {
38 va_list ap;
40 va_start (ap, fmt);
41 vfprintf (stderr, fmt, ap);
42 va_end (ap);
44 exit (2);
45 }
48 void *pdf_calloc (size_t nmemb, size_t size)
49 {
50 void *m = calloc (nmemb, size);
51 if (! m)
52 pdf_fatal ("failed to allocate memory\n");
53 return (m);
54 }
57 char *pdf_strdup (char *s)
58 {
59 unsigned long len = strlen (s);
60 char *s2 = pdf_calloc (1, len + 1);
61 strcpy (s2, s);
62 return (s2);
63 }