/src/ghostpdl/pcl/pcl/pcident.c
Line | Count | Source |
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 | | /* pcident.c - object identification mechanism for PCL */ |
18 | | |
19 | | #include "gx.h" |
20 | | #include "gsuid.h" |
21 | | #include "pcident.h" |
22 | | #include "pcstate.h" |
23 | | |
24 | | /* |
25 | | * Return the next unique identifier. |
26 | | * |
27 | | * Identifiers start at 8 to try to expose errors that might be masked by an |
28 | | * identifier of 0. In the unlikely event that so many identifiers are created |
29 | | * that the number wraps back to 0, the next assigned identifier will be |
30 | | * 16 * 1024 * 1024. This avoids potential overlap with permanent objects that |
31 | | * are assigned identifiers at initialization time. |
32 | | * |
33 | | * Special handling is also provided to avoid the no_UniqueID value used by |
34 | | * the graphic library. |
35 | | */ |
36 | | pcl_gsid_t |
37 | | pcl_next_id(pcl_state_t * pcs) |
38 | 56.9k | { |
39 | 56.9k | if (pcs->next_id == 0) |
40 | 0 | pcs->next_id = 16 * 1024 * 1024; |
41 | 56.9k | else if (pcs->next_id == no_UniqueID) |
42 | 0 | ++(pcs->next_id); |
43 | 56.9k | return (pcs->next_id)++; |
44 | 56.9k | } |