int gs_lib_ctx_init( gs_memory_t *mem ) { gs_lib_ctx_t *pio = 0; /* Check the non gc allocator is being passed in */ if (mem == 0 || mem != mem->non_gc_memory) return gs_error_Fatal; #ifndef GS_THREADSAFE mem_err_print = mem; #endif if (mem->gs_lib_ctx) /* one time initialization */ return 0; pio = (gs_lib_ctx_t*)gs_alloc_bytes_immovable(mem, sizeof(gs_lib_ctx_t), "gs_lib_ctx_init"); if( pio == 0 ) return -1; /* Wholesale blanking is cheaper than retail, and scales better when new * fields are added. */ memset(pio, 0, sizeof(*pio)); /* Now set the non zero/false/NULL things */ pio->memory = mem; gs_lib_ctx_get_real_stdio(&pio->fstdin, &pio->fstdout, &pio->fstderr ); pio->stdin_is_interactive = true; /* id's 1 through 4 are reserved for Device color spaces; see gscspace.h */ pio->gs_next_id = 5; /* this implies that each thread has its own complete state */ /* Need to set this before calling gs_lib_ctx_set_icc_directory. */ mem->gs_lib_ctx = pio; /* Initialize our default ICCProfilesDir */ pio->profiledir = NULL; pio->profiledir_len = 0; gs_lib_ctx_set_icc_directory(mem, DEFAULT_DIR_ICC, strlen(DEFAULT_DIR_ICC)); if (gs_lib_ctx_set_default_device_list(mem, gs_dev_defaults, strlen(gs_dev_defaults)) < 0) { gs_free_object(mem, pio, "gs_lib_ctx_init"); mem->gs_lib_ctx = NULL; } /* Initialise the underlying CMS. */ if (gscms_create(mem)) { gs_free_object(mem, mem->gs_lib_ctx->default_device_list, "gs_lib_ctx_fin"); gs_free_object(mem, pio, "gs_lib_ctx_init"); mem->gs_lib_ctx = NULL; return -1; } gp_get_realtime(pio->real_time_0); return 0; }
int gs_lib_ctx_init( gs_memory_t *mem ) { gs_lib_ctx_t *pio = 0; if ( mem == 0 ) return -1; /* assert mem != 0 */ mem_err_print = mem; if (mem->gs_lib_ctx) /* one time initialization */ return 0; pio = mem->gs_lib_ctx = (gs_lib_ctx_t*)gs_alloc_bytes_immovable(mem, sizeof(gs_lib_ctx_t), "gs_lib_ctx_init"); if( pio == 0 ) return -1; pio->memory = mem; gs_lib_ctx_get_real_stdio(&pio->fstdin, &pio->fstdout, &pio->fstderr ); pio->fstdout2 = NULL; pio->stdout_is_redirected = false; pio->stdout_to_stderr = false; pio->stdin_is_interactive = true; pio->stdin_fn = 0; pio->stdout_fn = 0; pio->stderr_fn = 0; pio->poll_fn = 0; pio->custom_color_callback = NULL; /* id's 1 through 4 are reserved for Device color spaces; see gscspace.h */ pio->gs_next_id = 5; /* this implies that each thread has its own complete state */ pio->dict_auto_expand = false; return 0; }
int gs_lib_ctx_init( gs_memory_t *mem ) { gs_lib_ctx_t *pio = 0; if ( mem == 0 ) return -1; /* assert mem != 0 */ mem_err_print = mem; if (mem->gs_lib_ctx) /* one time initialization */ return 0; pio = mem->gs_lib_ctx = (gs_lib_ctx_t*)gs_alloc_bytes_immovable(mem, sizeof(gs_lib_ctx_t), "gs_lib_ctx_init"); if( pio == 0 ) return -1; /* Wholesale blanking is cheaper than retail, and scales better when new * fields are added. */ memset(pio, 0, sizeof(*pio)); /* Now set the non zero/false/NULL things */ pio->memory = mem; gs_lib_ctx_get_real_stdio(&pio->fstdin, &pio->fstdout, &pio->fstderr ); pio->stdin_is_interactive = true; /* id's 1 through 4 are reserved for Device color spaces; see gscspace.h */ pio->gs_next_id = 5; /* this implies that each thread has its own complete state */ /* Initialize our default ICCProfilesDir */ pio->profiledir = NULL; pio->profiledir_len = 0; gs_lib_ctx_set_icc_directory(mem, DEFAULT_DIR_ICC, strlen(DEFAULT_DIR_ICC)); gp_get_realtime(pio->real_time_0); return 0; }