summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'base/gsdevice.c')
-rw-r--r--base/gsdevice.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/base/gsdevice.c b/base/gsdevice.c
index b02c324c..9af9403d 100644
--- a/base/gsdevice.c
+++ b/base/gsdevice.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2021 Artifex Software, Inc.
+/* Copyright (C) 2001-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -820,12 +820,8 @@ gx_device_raster(const gx_device * dev, bool pad)
/* depth can be <= num_components if planar and MEM_SET_PARAMS has changed it */
if (depth <= num_components || bpc >= 8) {
- /* tag plane requires at least 8 bits (per component as well as tags) */
- int has_tags = bpc >= 8 ? device_encodes_tags(dev): 0;
-
- bits /= (num_components + has_tags);
- }
- else {
+ bits /= num_components;
+ } else {
/* depth is original depth, not the plane_depth since it is > num_components */
bits /= (depth / bpc);
}
@@ -1206,13 +1202,15 @@ int gx_device_delete_output_file(const gx_device * dev, const char *fname)
const char *fmt;
char *pfname = (char *)gs_alloc_bytes(dev->memory, gp_file_name_sizeof, "gx_device_delete_output_file(pfname)");
int code;
+ size_t len;
if (pfname == NULL) {
code = gs_note_error(gs_error_VMerror);
goto done;
}
- code = gx_parse_output_file_name(&parsed, &fmt, fname, strlen(fname),
+ len = strlen(fname);
+ code = gx_parse_output_file_name(&parsed, &fmt, fname, len,
dev->memory);
if (code < 0) {
goto done;
@@ -1227,11 +1225,11 @@ int gx_device_delete_output_file(const gx_device * dev, const char *fname)
while (*fmt != 'l' && *fmt != '%')
--fmt;
if (*fmt == 'l')
- gs_sprintf(pfname, parsed.fname, count1);
+ gs_snprintf(pfname, len, parsed.fname, count1);
else
- gs_sprintf(pfname, parsed.fname, (int)count1);
+ gs_snprintf(pfname, len, parsed.fname, (int)count1);
} else if (parsed.len && strchr(parsed.fname, '%')) /* filename with "%%" but no "%nnd" */
- gs_sprintf(pfname, parsed.fname);
+ gs_snprintf(pfname, len, parsed.fname);
else
pfname[0] = 0; /* 0 to use "fname", not "pfname" */
if (pfname[0]) {
@@ -1304,11 +1302,11 @@ gx_device_open_output_file(const gx_device * dev, char *fname,
while (*fmt != 'l' && *fmt != '%')
--fmt;
if (*fmt == 'l')
- gs_sprintf(pfname, parsed.fname, count1);
+ gs_snprintf(pfname, gp_file_name_sizeof, parsed.fname, count1);
else
- gs_sprintf(pfname, parsed.fname, (int)count1);
+ gs_snprintf(pfname, gp_file_name_sizeof, parsed.fname, (int)count1);
} else if (parsed.len && strchr(parsed.fname, '%')) /* filename with "%%" but no "%nnd" */
- gs_sprintf(pfname, parsed.fname);
+ gs_snprintf(pfname, gp_file_name_sizeof, parsed.fname);
else
pfname[0] = 0; /* 0 to use "fname", not "pfname" */
if (pfname[0]) {
@@ -1435,3 +1433,25 @@ gdev_space_params_cmp(const gdev_space_params sp1,
return(0);
}
+
+static void
+release_nts_lock(gx_device *dev)
+{
+ (void)gs_lib_ctx_nts_adjust(dev->memory, -1);
+}
+
+int gx_init_non_threadsafe_device(gx_device *dev)
+{
+ int code;
+
+ if (dev == NULL || dev->finalize != NULL)
+ return gs_error_unknownerror;
+
+ code = gs_lib_ctx_nts_adjust(dev->memory, 1);
+ if (code < 0)
+ return code;
+
+ dev->finalize = release_nts_lock;
+
+ return 0;
+}