/src/ghostpdl/base/gsinit.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2023 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* Initialization for the imager */ |
18 | | #include "stdio_.h" |
19 | | #include "memory_.h" |
20 | | #include "gdebug.h" |
21 | | #include "gscdefs.h" |
22 | | #include "gsmemory.h" |
23 | | #include "gsmalloc.h" |
24 | | #include "gp.h" |
25 | | #include "gslib.h" /* interface definition */ |
26 | | #include "gxfapi.h" |
27 | | |
28 | | #include "valgrind.h" |
29 | | |
30 | | /* Configuration information from gconfig.c. */ |
31 | | extern_gx_init_table(); |
32 | | |
33 | | /* Initialization to be done before anything else. */ |
34 | | int |
35 | | gs_lib_init(gp_file * debug_out) |
36 | 0 | { |
37 | 0 | return gs_lib_init1(gs_lib_init0(debug_out)); |
38 | 0 | } |
39 | | gs_memory_t * |
40 | | gs_lib_init0(gp_file * debug_out) |
41 | 0 | { |
42 | | /* Reset debugging flags */ |
43 | 0 | #ifdef PACIFY_VALGRIND |
44 | 0 | VALGRIND_HG_DISABLE_CHECKING(gs_debug, 128); |
45 | 0 | #endif |
46 | 0 | memset(gs_debug, 0, 128); |
47 | 0 | gs_log_errors = 0; |
48 | |
|
49 | 0 | return (gs_memory_t *) gs_malloc_init(); |
50 | 0 | } |
51 | | int |
52 | | gs_lib_init1(gs_memory_t * mem) |
53 | 162k | { |
54 | | /* Run configuration-specific initialization procedures. */ |
55 | 162k | init_proc((*const *ipp)); |
56 | 162k | int code; |
57 | | |
58 | 812k | for (ipp = gx_init_table; *ipp != 0; ++ipp) |
59 | 649k | if ((code = (**ipp)(mem)) < 0) |
60 | 0 | return code; |
61 | 162k | return 0; |
62 | 162k | } |
63 | | |
64 | | /* Clean up after execution. */ |
65 | | void |
66 | | gs_lib_finit(int exit_status, int code, gs_memory_t *mem) |
67 | 162k | { |
68 | 162k | gs_fapi_finit (mem); |
69 | | |
70 | | /* Do platform-specific cleanup. */ |
71 | 162k | gp_exit(exit_status, code); |
72 | | |
73 | | /* NB: interface problem. |
74 | | * if gs_lib_init0 was called the we should |
75 | | * gs_malloc_release(mem); |
76 | | * else |
77 | | * someone else has control of mem so we can't free it. |
78 | | * gs_view and iapi.h interface |
79 | | */ |
80 | 162k | } |