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 /**
65  * art_dprint: Print the debug message to stderr.
66  * @fmt: The printf-style format for the debug message.
67  *
68  * Used for generating debug output.
69  **/
70 void
art_dprint(const char * fmt,...)71 art_dprint (const char *fmt, ...)
72 {
73   va_list ap;
74 
75   va_start (ap, fmt);
76   vfprintf (stderr, fmt, ap);
77   va_end (ap);
78 }
79 
art_alloc(size_t size)80 void *art_alloc(size_t size)
81 {
82   return malloc(size);
83 }
84 
art_free(void * ptr)85 void art_free(void *ptr)
86 {
87   free(ptr);
88 }
89 
art_realloc(void * ptr,size_t size)90 void *art_realloc(void *ptr, size_t size)
91 {
92   return realloc(ptr, size);
93 }
94