]> git.sesse.net Git - rdpsrv/blob - Xserver/lib/font/Type1/util.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / lib / font / Type1 / util.c
1 /* $XConsortium: util.c,v 1.7 94/01/27 15:21:15 gildea Exp $ */
2 /* Copyright International Business Machines,Corp. 1991
3  * All Rights Reserved
4  *
5  * License to use, copy, modify, and distribute this software
6  * and its documentation for any purpose and without fee is
7  * hereby granted, provided that the above copyright notice
8  * appear in all copies and that both that copyright notice and
9  * this permission notice appear in supporting documentation,
10  * and that the name of IBM not be used in advertising or
11  * publicity pertaining to distribution of the software without
12  * specific, written prior permission.
13  *
14  * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
15  * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
16  * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
18  * THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE QUALITY AND
19  * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
20  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF
21  * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
22  * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN
23  * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
25  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
26  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
27  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
28  * SOFTWARE.
29  */
30 /* Author: Katherine A. Hitchcock    IBM Almaden Research Laboratory */
31  
32 #include <stdio.h>
33 #include "util.h"
34 #include "fontmisc.h"
35  
36 static char *vm_base = NULL;  /* Start of virtual memory area */
37        char *vm_next = NULL;  /* Pointer to first free byte */
38        long  vm_free = 0;     /* Count of free bytes */
39        long  vm_size = 0;     /* Total size of memory */
40  
41 /*
42  * Initialize memory.
43  */
44 boolean vm_init(cnt)
45 int cnt;
46 {
47   vm_next = vm_base = (char *)xalloc (cnt);
48  
49   if (vm_base != NULL) {
50     vm_free = cnt;
51     vm_size = cnt;
52     return(TRUE);
53   }
54   else
55     return(FALSE);
56  
57 }
58  
59 char *vm_alloc(bytes)
60   int bytes;
61 {
62   char *answer;
63  
64   /* Round to next word multiple */
65   bytes = (bytes + 7) & ~7;
66  
67   /* Allocate the space, if it is available */
68   if (bytes <= vm_free) {
69     answer = vm_next;
70     vm_free -= bytes;
71     vm_next += bytes;
72   }
73   else
74     answer = NULL;
75  
76   return(answer);
77 }
78  
79 /*
80  * Format an Integer object
81  */
82 void objFormatInteger(objP,value)
83   psobj *objP;
84   int value;
85 {
86   if (objP != NULL) {
87     objP->type         = OBJ_INTEGER;
88     objP->len          = 0;
89     objP->data.integer = value;
90   }
91 }
92  
93 /*
94  * Format a Real object
95  */
96 void objFormatReal(objP,value)
97   psobj *objP;
98   float value;
99 {
100   if (objP != NULL) {
101     objP->type       = OBJ_REAL;
102     objP->len        = 0;
103     objP->data.real  = value;
104   }
105 }
106  
107 /*
108  * Format a Boolean object
109  */
110 void objFormatBoolean(objP,value)
111   psobj *objP;
112   boolean value;
113 {
114   if (objP != NULL) {
115     objP->type         = OBJ_BOOLEAN;
116     objP->len          = 0;
117     objP->data.boolean = value;
118   }
119 }
120  
121 /*
122  * Format an Encoding object
123  */
124 void objFormatEncoding(objP,length,valueP)
125   psobj *objP;
126   int length;
127   psobj *valueP;
128 {
129   if (objP != NULL) {
130     objP->type        = OBJ_ENCODING;
131     objP->len         = length;
132     objP->data.arrayP = valueP;
133   }
134 }
135  
136 /*
137  * Format an Array object
138  */
139 void objFormatArray(objP,length,valueP)
140   psobj *objP;
141   int length;
142   psobj *valueP;
143 {
144   if (objP != NULL) {
145     objP->type        = OBJ_ARRAY;
146     objP->len         = length;
147     objP->data.arrayP = valueP;
148   }
149 }
150  
151  
152 /*
153  * Format a String object
154  */
155 void objFormatString(objP,length,valueP)
156   psobj *objP;
157   int length;
158   char *valueP;
159 {
160   if (objP != NULL) {
161     objP->type         = OBJ_STRING;
162     objP->len          = length;
163     objP->data.valueP  = valueP;
164   }
165 }
166  
167 /*
168  * Format a Name object
169  */
170 void objFormatName(objP,length,valueP)
171   psobj *objP;
172   int length;
173   char *valueP;
174 {
175   if (objP != NULL) {
176     objP->type         = OBJ_NAME;
177     objP->len          = length;
178     objP->data.nameP   = valueP;
179   }
180 }
181  
182 /*
183  * Format a File object
184  */
185 void objFormatFile(objP,valueP)
186   psobj *objP;
187   FILE *valueP;
188 {
189   if (objP != NULL) {
190     objP->type         = OBJ_FILE;
191     objP->len          = 0;
192     objP->data.fileP   = valueP;
193   }
194 }
195