1 /* Libart_LGPL - library of basic graphic primitives
2  * Copyright (C) 1998 Raph Levien
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 /* Various utility functions RLL finds useful. */
21 
22 #include "config.h"
23 #include "art_misc.h"
24 
25 #ifdef HAVE_UINSTD_H
26 #	include <unistd.h>
27 #endif
28 #include <stdio.h>
29 #include <stdarg.h>
30 
31 /**
32  * art_die: Print the error message to stderr and exit with a return code of 1.
33  * @fmt: The printf-style format for the error message.
34  *
35  * Used for dealing with severe errors.
36  **/
37 void
art_die(const char * fmt,...)38 art_die (const char *fmt, ...)
39 {
40   va_list ap;
41 
42   va_start (ap, fmt);
43   vfprintf (stderr, fmt, ap);
44   va_end (ap);
45   exit (1);
46 }
47 
48 /**
49  * art_warn: Print the warning message to stderr.
50  * @fmt: The printf-style format for the warning message.
51  *
52  * Used for generating warnings.
53  **/
54 void
art_warn(const char * fmt,...)55 art_warn (const char *fmt, ...)
56 {
57   va_list ap;
58 
59   va_start (ap, fmt);
60   vfprintf (stderr, fmt, ap);
61   va_end (ap);
62 }
63 /**
64  * art_dprint: Print the debug message to stderr.
65  * @fmt: The printf-style format for the debug message.
66  *
67  * Used for generating debug output.
68  **/
69 void
art_dprint(const char * fmt,...)70 art_dprint (const char *fmt, ...)
71 {
72   va_list ap;
73 
74   va_start (ap, fmt);
75 #ifndef	NOSTDERR
76   vfprintf (stderr, fmt, ap);
77 #else
78   vfprintf (stdout, fmt, ap);
79 #endif
80   va_end (ap);
81 }
82 
art_alloc(size_t size)83 void *art_alloc(size_t size)
84 {
85   return malloc(size);
86 }
87 
art_free(void * ptr)88 void art_free(void *ptr)
89 {
90   free(ptr);
91 }
92 
art_realloc(void * ptr,size_t size)93 void *art_realloc(void *ptr, size_t size)
94 {
95   return realloc(ptr, size);
96 }
97