Bug Summary

File:Resources.c
Location:line 1034, column 5
Description:Array access (from variable 'classes') results in a null pointer dereference

Annotated Source Code

1/***********************************************************
2Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved.
3
4Permission is hereby granted, free of charge, to any person obtaining a
5copy of this software and associated documentation files (the "Software"),
6to deal in the Software without restriction, including without limitation
7the rights to use, copy, modify, merge, publish, distribute, sublicense,
8and/or sell copies of the Software, and to permit persons to whom the
9Software is furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice (including the next
12paragraph) shall be included in all copies or substantial portions of the
13Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21DEALINGS IN THE SOFTWARE.
22
23Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
24
25 All Rights Reserved
26
27Permission to use, copy, modify, and distribute this software and its
28documentation for any purpose and without fee is hereby granted,
29provided that the above copyright notice appear in all copies and that
30both that copyright notice and this permission notice appear in
31supporting documentation, and that the name of Digital not be
32used in advertising or publicity pertaining to distribution of the
33software without specific, written prior permission.
34
35DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
36ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
37DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
38ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
39WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
40ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
41SOFTWARE.
42
43******************************************************************/
44
45/*
46
47Copyright 1987, 1988, 1994, 1998 The Open Group
48
49Permission to use, copy, modify, distribute, and sell this software and its
50documentation for any purpose is hereby granted without fee, provided that
51the above copyright notice appear in all copies and that both that
52copyright notice and this permission notice appear in supporting
53documentation.
54
55The above copyright notice and this permission notice shall be included in
56all copies or substantial portions of the Software.
57
58THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
62AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
63CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64
65Except as contained in this notice, the name of The Open Group shall not be
66used in advertising or otherwise to promote the sale, use or other dealings
67in this Software without prior written authorization from The Open Group.
68
69*/
70
71/*LINTLIBRARY*/
72#ifdef HAVE_CONFIG_H1
73#include <config.h>
74#endif
75#include "IntrinsicI.h"
76#include "VarargsI.h"
77#include "Shell.h"
78#include "ShellP.h"
79#include "StringDefs.h"
80#include <stdio.h>
81
82static XrmClass QBoolean, QString, QCallProc, QImmediate;
83static XrmName QinitialResourcesPersistent, QInitialResourcesPersistent;
84static XrmClass QTranslations, QTranslationTable;
85static XrmName Qtranslations, QbaseTranslations;
86static XrmName Qscreen;
87static XrmClass QScreen;
88
89#ifdef CRAY
90void Cjump();
91char *Cjumpp = (char *) Cjump;
92void Cjump() {}
93#endif
94
95void _XtCopyFromParent(
96 Widget widget,
97 int offset,
98 XrmValue *value)
99{
100 if (widget->core.parent == NULL((void*)0)) {
101 XtAppWarningMsg(XtWidgetToApplicationContext(widget),
102 "invalidParent","xtCopyFromParent",XtCXtToolkitError,
103 "CopyFromParent must have non-NULL parent",
104 (String *)NULL((void*)0), (Cardinal *)NULL((void*)0));
105 value->addr = NULL((void*)0);
106 return;
107 }
108 value->addr = (XPointer)(((char *)widget->core.parent) + offset);
109} /* _XtCopyFromParent */
110
111
112void _XtCopyFromArg(
113 XtArgVal src,
114 char* dst,
115 register unsigned int size)
116{
117 if (size > sizeof(XtArgVal))
118 (void) memmove((char *) dst, (char *) src, (int) size);
119 else {
120 union {
121 long longval;
122#ifdef LONG64
123 int intval;
124#endif
125 short shortval;
126 char charval;
127 char* charptr;
128 XtPointer ptr;
129 } u;
130 char *p = (char*)&u;
131 if (size == sizeof(long)) u.longval = (long)src;
132#ifdef LONG64
133 else if (size == sizeof(int)) u.intval = (int)src;
134#endif
135 else if (size == sizeof(short)) u.shortval = (short)src;
136 else if (size == sizeof(char)) u.charval = (char)src;
137 else if (size == sizeof(XtPointer)) u.ptr = (XtPointer)src;
138 else if (size == sizeof(char*)) u.charptr = (char*)src;
139 else p = (char*)&src;
140
141 (void) memmove(dst, p, (int) size);
142 }
143} /* _XtCopyFromArg */
144
145void _XtCopyToArg(
146 char* src,
147 XtArgVal *dst,
148 register unsigned int size)
149{
150 if (!*dst) {
151#ifdef GETVALUES_BUG
152 /* old GetValues semantics (storing directly into arglists) are bad,
153 * but preserve for compatibility as long as arglist contains NULL.
154 */
155 union {
156 long longval;
157#ifdef LONG64
158 int intval;
159#endif
160 short shortval;
161 char charval;
162 char* charptr;
163 XtPointer ptr;
164 } u;
165 if (size <= sizeof(XtArgVal)) {
166 (void) memmove((char*)&u, (char*)src, (int)size );
167 if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
168#ifdef LONG64
169 else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
170#endif
171 else if (size == sizeof(short)) *dst = (XtArgVal)u.shortval;
172 else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
173 else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
174 else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
175 else (void) memmove((char*)dst, (char*)src, (int)size );
176 }
177 else
178 (void) memmove((char*)dst, (char*)src, (int)size );
179#else
180 XtErrorMsg("invalidGetValues", "xtGetValues", XtCXtToolkitError,
181 "NULL ArgVal in XtGetValues", (String*) NULL((void*)0), (Cardinal*) NULL((void*)0));
182#endif
183 }
184 else {
185 /* proper GetValues semantics: argval is pointer to destination */
186 (void) memmove((char*)*dst, (char*)src, (int)size );
187 }
188} /* _XtCopyToArg */
189
190static void CopyToArg(
191 char* src,
192 XtArgVal *dst,
193 register unsigned int size)
194{
195 if (!*dst) {
196 /* old GetValues semantics (storing directly into arglists) are bad,
197 * but preserve for compatibility as long as arglist contains NULL.
198 */
199 union {
200 long longval;
201#ifdef LONG64
202 int intval;
203#endif
204 short shortval;
205 char charval;
206 char* charptr;
207 XtPointer ptr;
208 } u;
209 if (size <= sizeof(XtArgVal)) {
210 (void) memmove((char*)&u, (char*)src, (int)size );
211 if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
212#ifdef LONG64
213 else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
214#endif
215 else if (size == sizeof(short)) *dst = (XtArgVal)u.shortval;
216 else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
217 else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
218 else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
219 else (void) memmove((char*)dst, (char*)src, (int)size );
220 }
221 else
222 (void) memmove((char*)dst, (char*)src, (int)size );
223 }
224 else {
225 /* proper GetValues semantics: argval is pointer to destination */
226 (void) memmove((char*)*dst, (char*)src, (int)size );
227 }
228} /* CopyToArg */
229
230
231static Cardinal CountTreeDepth(
232 Widget w)
233{
234 Cardinal count;
235
236 for (count = 1; w != NULL((void*)0); w = (Widget) w->core.parent)
237 count++;
238
239 return count;
240}
241
242static void GetNamesAndClasses(
243 register Widget w,
244 register XrmNameList names,
245 register XrmClassList classes)
246{
247 register Cardinal length, j;
248 register XrmQuark t;
249 WidgetClass class;
250
251 /* Return null-terminated quark arrays, with length the number of
252 quarks (not including NULL) */
253
254 LOCK_PROCESSif(_XtProcessLock)(*_XtProcessLock)();
255 for (length = 0; w != NULL((void*)0); w = (Widget) w->core.parent) {
256 names[length] = w->core.xrm_name;
257 class = XtClass(w)((w)->core.widget_class);
258 /* KLUDGE KLUDGE KLUDGE KLUDGE */
259 if (w->core.parent == NULL((void*)0) && XtIsApplicationShell(w)(_XtIsSubclassOf(w, (WidgetClass)applicationShellWidgetClass,
(WidgetClass)topLevelShellWidgetClass, (XtEnum)0x80))
) {
260 classes[length] =
261 ((ApplicationShellWidget) w)->application.xrm_class;
262 } else classes[length] = class->core_class.xrm_class;
263 length++;
264 }
265 UNLOCK_PROCESSif(_XtProcessUnlock)(*_XtProcessUnlock)();
266 /* They're in backwards order, flop them around */
267 for (j = 0; j < length/2; j++) {
268 t = names[j];
269 names[j] = names[length-j-1];
270 names[length-j-1] = t;
271 t = classes[j];
272 classes[j] = classes[length-j-1];
273 classes[length-j-1] = t;
274 }
275 names[length] = NULLQUARK((XrmQuark) 0);
276 classes[length] = NULLQUARK((XrmQuark) 0);
277} /* GetNamesAndClasses */
278
279
280/* Spiffy fast compiled form of resource list. */
281/* XtResourceLists are compiled in-place into XrmResourceLists */
282/* All atoms are replaced by quarks, and offsets are -offset-1 to */
283/* indicate that this list has been compiled already */
284
285void _XtCompileResourceList(
286 register XtResourceList resources,
287 Cardinal num_resources)
288{
289 register Cardinal count;
290
291#define xrmres ((XrmResourceList) resources)
292#define PSToQ XrmPermStringToQuark
293
294 for (count = 0; count < num_resources; resources++, count++) {
295 xrmres->xrm_name = PSToQ(resources->resource_name);
296 xrmres->xrm_class = PSToQ(resources->resource_class);
297 xrmres->xrm_type = PSToQ(resources->resource_type);
298 xrmres->xrm_offset = (Cardinal)
299 (-(int)resources->resource_offset - 1);
300 xrmres->xrm_default_type = PSToQ(resources->default_type);
301 }
302#undef PSToQ
303#undef xrmres
304} /* _XtCompileResourceList */
305
306/* Like _XtCompileResourceList, but strings are not permanent */
307static void XrmCompileResourceListEphem(
308 register XtResourceList resources,
309 Cardinal num_resources)
310{
311 register Cardinal count;
312
313#define xrmres ((XrmResourceList) resources)
314
315 for (count = 0; count < num_resources; resources++, count++) {
316 xrmres->xrm_name = StringToName(resources->resource_name)XrmStringToQuark(resources->resource_name);
317 xrmres->xrm_class = StringToClass(resources->resource_class)XrmStringToQuark(resources->resource_class);
318 xrmres->xrm_type = StringToQuark(resources->resource_type)XrmStringToQuark(resources->resource_type);
319 xrmres->xrm_offset = (Cardinal)
320 (-(int)resources->resource_offset - 1);
321 xrmres->xrm_default_type = StringToQuark(resources->default_type)XrmStringToQuark(resources->default_type);
322 }
323#undef xrmres
324} /* XrmCompileResourceListEphem */
325
326static void BadSize(
327 Cardinal size,
328 XrmQuark name)
329{
330 String params[2];
331 Cardinal num_params = 2;
332
333 params[0] = (String)(long) size;
334 params[1] = XrmQuarkToString(name);
335 XtWarningMsg("invalidSizeOverride", "xtDependencies", XtCXtToolkitError,
336 "Representation size %d must match superclass's to override %s",
337 params, &num_params);
338} /* BadType */
339
340/*
341 * Create a new resource list, with the class resources following the
342 * superclass's resources. If a resource in the class list overrides
343 * a superclass resource, then just replace the superclass entry in place.
344 *
345 * At the same time, add a level of indirection to the XtResourceList to
346 * create and XrmResourceList.
347 */
348void _XtDependencies(
349 XtResourceList *class_resp, /* VAR */
350 Cardinal *class_num_resp, /* VAR */
351 XrmResourceList *super_res,
352 Cardinal super_num_res,
353 Cardinal super_widget_size)
354{
355 register XrmResourceList *new_res;
356 Cardinal new_num_res;
357 XrmResourceList class_res = (XrmResourceList) *class_resp;
358 Cardinal class_num_res = *class_num_resp;
359 register Cardinal i, j;
360 Cardinal new_next;
361
362 if (class_num_res == 0) {
363 /* Just point to superclass resource list */
364 *class_resp = (XtResourceList) super_res;
365 *class_num_resp = super_num_res;
366 return;
367 }
368
369 /* Allocate and initialize new_res with superclass resource pointers */
370 new_num_res = super_num_res + class_num_res;
371 new_res = (XrmResourceList *) __XtMalloc(new_num_res*sizeof(XrmResourceList));
372 if (super_num_res > 0)
373 XtMemmove(new_res, super_res, super_num_res * sizeof(XrmResourceList))if ((char *)(new_res) != (char *)(super_res)) { (void) memcpy
((char *) (new_res), (char *) (super_res), (int) (super_num_res
* sizeof(XrmResourceList))); }
;
374
375 /* Put pointers to class resource entries into new_res */
376 new_next = super_num_res;
377 for (i = 0; i < class_num_res; i++) {
378 if ((Cardinal)(-class_res[i].xrm_offset-1) < super_widget_size) {
379 /* Probably an override of superclass resources--look for overlap */
380 for (j = 0; j < super_num_res; j++) {
381 if (class_res[i].xrm_offset == new_res[j]->xrm_offset) {
382 /* Spec is silent on what fields subclass can override.
383 * The only two of real concern are type & size.
384 * Although allowing type to be over-ridden introduces
385 * the possibility of errors, it's at present the only
386 * reasonable way to allow a subclass to force a private
387 * converter to be invoked for a subset of fields.
388 */
389 /* We do insist that size be identical to superclass */
390 if (class_res[i].xrm_size != new_res[j]->xrm_size) {
391 BadSize(class_res[i].xrm_size,
392 (XrmQuark) class_res[i].xrm_name);
393 class_res[i].xrm_size = new_res[j]->xrm_size;
394 }
395 new_res[j] = &(class_res[i]);
396 new_num_res--;
397 goto NextResource;
398 }
399 } /* for j */
400 }
401 /* Not an overlap, add an entry to new_res */
402 new_res[new_next++] = &(class_res[i]);
403NextResource:;
404 } /* for i */
405
406 /* Okay, stuff new resources back into class record */
407 *class_resp = (XtResourceList) new_res;
408 *class_num_resp = new_num_res;
409} /* _XtDependencies */
410
411
412void _XtResourceDependencies(
413 WidgetClass wc)
414{
415 WidgetClass sc;
416
417 sc = wc->core_class.superclass;
418 if (sc == NULL((void*)0)) {
419 _XtDependencies(&(wc->core_class.resources),
420 &(wc->core_class.num_resources),
421 (XrmResourceList *) NULL((void*)0), (unsigned)0, (unsigned)0);
422 } else {
423 _XtDependencies(&(wc->core_class.resources),
424 &(wc->core_class.num_resources),
425 (XrmResourceList *) sc->core_class.resources,
426 sc->core_class.num_resources,
427 sc->core_class.widget_size);
428 }
429} /* _XtResourceDependencies */
430
431void _XtConstraintResDependencies(
432 ConstraintWidgetClass wc)
433{
434 ConstraintWidgetClass sc;
435
436 if (wc == (ConstraintWidgetClass) constraintWidgetClass) {
437 _XtDependencies(&(wc->constraint_class.resources),
438 &(wc->constraint_class.num_resources),
439 (XrmResourceList *)NULL((void*)0), (unsigned)0, (unsigned)0);
440 } else {
441 sc = (ConstraintWidgetClass) wc->core_class.superclass;
442 _XtDependencies(&(wc->constraint_class.resources),
443 &(wc->constraint_class.num_resources),
444 (XrmResourceList *) sc->constraint_class.resources,
445 sc->constraint_class.num_resources,
446 sc->constraint_class.constraint_size);
447 }
448} /* _XtConstraintResDependencies */
449
450
451
452
453XrmResourceList* _XtCreateIndirectionTable (
454 XtResourceList resources,
455 Cardinal num_resources)
456{
457 register Cardinal idx;
458 XrmResourceList* table;
459
460 table = (XrmResourceList*)__XtMalloc(num_resources * sizeof(XrmResourceList));
461 for (idx = 0; idx < num_resources; idx++)
462 table[idx] = (XrmResourceList)(&(resources[idx]));
463 return table;
464}
465
466static XtCacheRef *GetResources(
467 Widget widget, /* Widget resources are associated with */
468 char* base, /* Base address of memory to write to */
469 XrmNameList names, /* Full inheritance name of widget */
470 XrmClassList classes, /* Full inheritance class of widget */
471 XrmResourceList* table, /* The list of resources required. */
472 unsigned num_resources, /* number of items in resource list */
473 XrmQuarkList quark_args, /* Arg names quarkified */
474 ArgList args, /* ArgList to override resources */
475 unsigned num_args, /* number of items in arg list */
476 XtTypedArgList typed_args, /* Typed arg list to override resources */
477 Cardinal* pNumTypedArgs, /* number of items in typed arg list */
478 Boolean tm_hack) /* do baseTranslations */
479{
480/*
481 * assert: *pNumTypedArgs == 0 if num_args > 0
482 * assert: num_args == 0 if *pNumTypedArgs > 0
483 */
484#define SEARCHLISTLEN100 100
485#define MAXRESOURCES400 400
486
487 XrmValue value;
488 XrmQuark rawType;
489 XrmValue convValue;
490 XrmHashTable stackSearchList[SEARCHLISTLEN100];
491 XrmHashTable *searchList = stackSearchList;
492 unsigned int searchListSize = SEARCHLISTLEN100;
493 Boolean found[MAXRESOURCES400];
494 int typed[MAXRESOURCES400];
495 XtCacheRef cache_ref[MAXRESOURCES400];
496 XtCacheRef *cache_ptr, *cache_base;
497 Boolean persistent_resources = True1;
498 Boolean found_persistence = False0;
499 int num_typed_args = *pNumTypedArgs;
500 XrmDatabase db;
501 Boolean do_tm_hack = False0;
502
503 if ((args == NULL((void*)0)) && (num_args != 0)) {
504 XtAppWarningMsg(XtWidgetToApplicationContext(widget),
505 "invalidArgCount","getResources",XtCXtToolkitError,
506 "argument count > 0 on NULL argument list",
507 (String *)NULL((void*)0), (Cardinal *)NULL((void*)0));
508 num_args = 0;
509 }
510 if (num_resources == 0) {
511 return NULL((void*)0);
512 } else if (num_resources >= MAXRESOURCES400) {
513 XtAppWarningMsg(XtWidgetToApplicationContext(widget),
514 "invalidResourceCount","getResources",XtCXtToolkitError,
515 "too many resources",
516 (String *)NULL((void*)0), (Cardinal *)NULL((void*)0));
517 return NULL((void*)0);
518 } else if (table == NULL((void*)0)) {
519 XtAppWarningMsg(XtWidgetToApplicationContext(widget),
520 "invalidResourceCount","getResources",XtCXtToolkitError,
521 "resource count > 0 on NULL resource list",
522 (String *)NULL((void*)0), (Cardinal *)NULL((void*)0));
523 return NULL((void*)0);
524 }
525
526 /* Mark each resource as not found on arg list */
527 bzero((char *) found, (int) (num_resources * sizeof(Boolean)))memset((char *) found,0,(int) (num_resources * sizeof(Boolean
)))
;
528 bzero((char *) typed, (int) (num_resources * sizeof(int)))memset((char *) typed,0,(int) (num_resources * sizeof(int)));
529
530 /* Copy the args into the resources, mark each as found */
531 {
532 register ArgList arg;
533 register XtTypedArgList typed_arg;
534 register XrmName argName;
535 register Cardinal j;
536 register int i;
537 register XrmResourceList rx;
538 register XrmResourceList *res;
539 for (arg = args, i = 0; (Cardinal)i < num_args; i++, arg++) {
540 argName = quark_args[i];
541 if (argName == QinitialResourcesPersistent) {
542 persistent_resources = (Boolean)arg->value;
543 found_persistence = True1;
544 continue;
545 }
546 for (j = 0, res = table; j < num_resources; j++, res++) {
547 rx = *res;
548 if (argName == rx->xrm_name) {
549 _XtCopyFromArg(
550 arg->value,
551 base - rx->xrm_offset - 1,
552 rx->xrm_size);
553 found[j] = TRUE1;
554 break;
555 }
556 }
557 }
558 for (typed_arg = typed_args, i = 0; i < num_typed_args;
559 i++, typed_arg++) {
560 register XrmRepresentation argType;
561 argName = quark_args[i];
562 argType = (typed_arg->type == NULL((void*)0)) ? NULLQUARK((XrmQuark) 0)
563 : XrmStringToRepresentation(typed_arg->type)XrmStringToQuark(typed_arg->type);
564 if (argName == QinitialResourcesPersistent) {
565 persistent_resources = (Boolean)typed_arg->value;
566 found_persistence = True1;
567 break;
568 }
569 for (j = 0, res = table; j < num_resources; j++, res++) {
570 rx = *res;
571 if (argName == rx->xrm_name) {
572 if (argType != NULLQUARK((XrmQuark) 0) && argType != rx->xrm_type) {
573 typed[j] = i + 1;
574 } else {
575 _XtCopyFromArg(
576 typed_arg->value,
577 base - rx->xrm_offset - 1,
578 rx->xrm_size);
579 }
580 found[j] = TRUE1;
581 break;
582 }
583 }
584 }
585 }
586
587 /* Ask resource manager for a list of database levels that we can
588 do a single-level search on each resource */
589
590 db = XtScreenDatabase(XtScreenOfObject(widget)((((Object)(widget))->object.widget_class->core_class.class_inited
& 0x04) ? (widget)->core.screen : _XtIsHookObject(widget
) ? ((HookObject)(widget))->hooks.screen : _XtWindowedAncestor
(widget)->core.screen)
);
591 while (!XrmQGetSearchList(db, names, classes,
592 searchList, searchListSize)) {
593 if (searchList == stackSearchList)
594 searchList = NULL((void*)0);
595 searchList = (XrmHashTable*)XtRealloc((char*)searchList,
596 sizeof(XrmHashTable) *
597 (searchListSize *= 2));
598 }
599
600 if (persistent_resources)
601 cache_base = NULL((void*)0);
602 else
603 cache_base = cache_ref;
604 /* geez, this is an ugly mess */
605 if (XtIsShell(widget)(((Object)(widget))->object.widget_class->core_class.class_inited
& 0x20)
) {
606 register XrmResourceList *res;
607 register Cardinal j;
608 Screen *oldscreen = widget->core.screen;
609
610 /* look up screen resource first, since real rdb depends on it */
611 for (res = table, j = 0; j < num_resources; j++, res++) {
612 if ((*res)->xrm_name != Qscreen)
613 continue;
614 if (typed[j]) {
615 register XtTypedArg* arg = typed_args + typed[j] - 1;
616 XrmQuark from_type;
617 XrmValue from_val, to_val;
618
619 from_type = StringToQuark(arg->type)XrmStringToQuark(arg->type);
620 from_val.size = arg->size;
621 if ((from_type == QString) || ((unsigned) arg->size > sizeof(XtArgVal)))
622 from_val.addr = (XPointer)arg->value;
623 else
624 from_val.addr = (XPointer)&arg->value;
625 to_val.size = sizeof(Screen*);
626 to_val.addr = (XPointer)&widget->core.screen;
627 found[j] = _XtConvert(widget, from_type, &from_val,
628 QScreen, &to_val, cache_base);
629 if (cache_base && *cache_base)
630 cache_base++;
631 }
632 if (!found[j]) {
633 if (XrmQGetSearchResource(searchList, Qscreen, QScreen,
634 &rawType, &value)) {
635 if (rawType != QScreen) {
636 convValue.size = sizeof(Screen*);
637 convValue.addr = (XPointer)&widget->core.screen;
638 (void)_XtConvert(widget, rawType, &value,
639 QScreen, &convValue, cache_base);
640 if (cache_base && *cache_base)
641 cache_base++;
642 } else {
643 widget->core.screen = *((Screen **)value.addr);
644 }
645 }
646 }
647 break;
648 }
649 /* now get the database to use for the rest of the resources */
650 if (widget->core.screen != oldscreen) {
651 db = XtScreenDatabase(widget->core.screen);
652 while (!XrmQGetSearchList(db, names, classes,
653 searchList, searchListSize)) {
654 if (searchList == stackSearchList)
655 searchList = NULL((void*)0);
656 searchList = (XrmHashTable*)XtRealloc((char*)searchList,
657 sizeof(XrmHashTable) *
658 (searchListSize *= 2));
659 }
660 }
661 }
662
663 /* go to the resource manager for those resources not found yet */
664 /* if it's not in the resource database use the default value */
665
666 {
667 register XrmResourceList rx;
668 register XrmResourceList *res;
669 register Cardinal j;
670 register XrmRepresentation xrm_type;
671 register XrmRepresentation xrm_default_type;
672 char char_val;
673 short short_val;
674 int int_val;
675 long long_val;
676 char* char_ptr;
677
678 if (!found_persistence) {
679 if (XrmQGetSearchResource(searchList, QinitialResourcesPersistent,
680 QInitialResourcesPersistent, &rawType, &value)) {
681 if (rawType != QBoolean) {
682 convValue.size = sizeof(Boolean);
683 convValue.addr = (XPointer)&persistent_resources;
684 (void)_XtConvert(widget, rawType, &value, QBoolean,
685 &convValue, NULL((void*)0));
686 }
687 else
688 persistent_resources = *(Boolean*)value.addr;
689 }
690 }
691 if (persistent_resources)
692 cache_ptr = NULL((void*)0);
693 else if (cache_base)
694 cache_ptr = cache_base;
695 else
696 cache_ptr = cache_ref;
697
698 for (res = table, j = 0; j < num_resources; j++, res++) {
699 rx = *res;
700 xrm_type = rx->xrm_type;
701 if (typed[j]) {
702 register XtTypedArg* arg = typed_args + typed[j] - 1;
703
704 /*
705 * This resource value has been specified as a typed arg and
706 * has to be converted. Typed arg conversions are done here
707 * to correctly interpose them with normal resource conversions.
708 */
709 XrmQuark from_type;
710 XrmValue from_val, to_val;
711 Boolean converted;
712
713 from_type = StringToQuark(arg->type)XrmStringToQuark(arg->type);
714 from_val.size = arg->size;
715 if ((from_type == QString) || ((unsigned) arg->size > sizeof(XtArgVal)))
716 from_val.addr = (XPointer)arg->value;
717 else
718 from_val.addr = (XPointer)&arg->value;
719 to_val.size = rx->xrm_size;
720 to_val.addr = base - rx->xrm_offset - 1;
721 converted = _XtConvert(widget, from_type, &from_val,
722 xrm_type, &to_val, cache_ptr);
723 if (converted) {
724
725 /* Copy the converted value back into the typed argument.
726 * normally the data should be <= sizeof(XtArgVal) and
727 * is stored directly into the 'value' field .... BUT
728 * if the resource size is greater than sizeof(XtArgVal)
729 * then we dynamically alloc a block of store to hold the
730 * data and zap a copy in there !!! .... freeing it later
731 * the size field in the typed arg is negated to indicate
732 * that the store pointed to by the value field is
733 * dynamic .......
734 * "freeing" happens in the case of _XtCreate after the
735 * CallInitialize ..... other clients of GetResources
736 * using typed args should be aware of the need to free
737 * this store .....
738 */
739
740 if(rx->xrm_size > sizeof(XtArgVal)) {
741 arg->value = (XtArgVal) __XtMalloc(rx->xrm_size);
742 arg->size = -(arg->size);
743 } else { /* will fit - copy directly into value field */
744 arg->value = (XtArgVal) NULL((void*)0);
745 }
746 CopyToArg((char *)(base - rx->xrm_offset - 1),
747 &arg->value, rx->xrm_size);
748
749 } else {
750 /* Conversion failed. Get default value. */
751 found[j] = False0;
752 }
753
754 if (cache_ptr && *cache_ptr)
755 cache_ptr++;
756 }
757
758 if (!found[j]) {
759 Boolean already_copied = False0;
760 Boolean have_value = False0;
761
762 if (XrmQGetSearchResource(searchList,
763 rx->xrm_name, rx->xrm_class, &rawType, &value)) {
764 if (rawType != xrm_type) {
765 convValue.size = rx->xrm_size;
766 convValue.addr = (XPointer)(base - rx->xrm_offset - 1);
767 already_copied = have_value =
768 _XtConvert(widget, rawType, &value,
769 xrm_type, &convValue, cache_ptr);
770 if (cache_ptr && *cache_ptr)
771 cache_ptr++;
772 } else have_value = True1;
773 if (have_value && rx->xrm_name == Qtranslations)
774 do_tm_hack = True1;
775 }
776 LOCK_PROCESSif(_XtProcessLock)(*_XtProcessLock)();
777 if (!have_value
778 && ((rx->xrm_default_type == QImmediate)
779 || (rx->xrm_default_type == xrm_type)
780 || (rx->xrm_default_addr != NULL((void*)0)))) {
781 /* Convert default value to proper type */
782 xrm_default_type = rx->xrm_default_type;
783 if (xrm_default_type == QCallProc) {
784#ifdef CRAY
785 if ( (int) Cjumpp != (int) Cjump)
786 (*(XtResourceDefaultProc)
787 (((int)(rx->xrm_default_addr))<<2))(
788 widget,-(rx->xrm_offset+1), &value);
789 else
790#endif
791 (*(XtResourceDefaultProc)(rx->xrm_default_addr))(
792 widget,-(rx->xrm_offset+1), &value);
793
794 } else if (xrm_default_type == QImmediate) {
795 /* XtRImmediate == XtRString for type XtRString */
796 if (xrm_type == QString) {
797 value.addr = rx->xrm_default_addr;
798 } else if (rx->xrm_size == sizeof(int)) {
799 int_val = (int)(long)rx->xrm_default_addr;
800 value.addr = (XPointer) &int_val;
801 } else if (rx->xrm_size == sizeof(short)) {
802 short_val = (short)(long)rx->xrm_default_addr;
803 value.addr = (XPointer) &short_val;
804 } else if (rx->xrm_size == sizeof(char)) {
805 char_val = (char)(long)rx->xrm_default_addr;
806 value.addr = (XPointer) &char_val;
807 } else if (rx->xrm_size == sizeof(long)) {
808 long_val = (long)rx->xrm_default_addr;
809 value.addr = (XPointer) &long_val;
810 } else if (rx->xrm_size == sizeof(char*)) {
811 char_ptr = (char*)rx->xrm_default_addr;
812 value.addr = (XPointer) &char_ptr;
813 } else {
814 value.addr = (XPointer) &(rx->xrm_default_addr);
815 }
816 } else if (xrm_default_type == xrm_type) {
817 value.addr = rx->xrm_default_addr;
818 } else {
819 value.addr = rx->xrm_default_addr;
820 if (xrm_default_type == QString) {
821 value.size = strlen((char *)value.addr) + 1;
822 } else {
823 value.size = sizeof(XtPointer);
824 }
825 convValue.size = rx->xrm_size;
826 convValue.addr = (XPointer)(base - rx->xrm_offset - 1);
827 already_copied =
828 _XtConvert(widget, xrm_default_type, &value,
829 xrm_type, &convValue, cache_ptr);
830 if (!already_copied)
831 value.addr = NULL((void*)0);
832 if (cache_ptr && *cache_ptr)
833 cache_ptr++;
834 }
835 }
836 if (!already_copied) {
837 if (xrm_type == QString) {
838 *((String*)(base - rx->xrm_offset - 1)) = value.addr;
839 } else {
840 if (value.addr != NULL((void*)0)) {
841 XtMemmove(base - rx->xrm_offset - 1,if ((char *)(base - rx->xrm_offset - 1) != (char *)(value.
addr)) { (void) memcpy((char *) (base - rx->xrm_offset - 1
), (char *) (value.addr), (int) (rx->xrm_size)); }
842 value.addr, rx->xrm_size)if ((char *)(base - rx->xrm_offset - 1) != (char *)(value.
addr)) { (void) memcpy((char *) (base - rx->xrm_offset - 1
), (char *) (value.addr), (int) (rx->xrm_size)); }
;
843 } else {
844 /* didn't get value, initialize to NULL... */
845 XtBZero(base - rx->xrm_offset - 1, rx->xrm_size)memset((char *) (base - rx->xrm_offset - 1),0,(int) (rx->
xrm_size))
;
846 }
847 }
848 }
849 UNLOCK_PROCESSif(_XtProcessUnlock)(*_XtProcessUnlock)();
850 }
851 }
852 for (res = table, j = 0; j < num_resources; j++, res++) {
853 if (!found[j] && typed[j]) {
854 /*
855 * This resource value was specified as a typed arg.
856 * However, the default value is being used here since
857 * type type conversion failed, so we compress the list.
858 */
859 register XtTypedArg* arg = typed_args + typed[j] - 1;
860 register int i;
861
862 for (i = num_typed_args - typed[j]; i > 0; i--, arg++) {
863 *arg = *(arg+1);
864 }
865 num_typed_args--;
866 }
867 }
868 if (tm_hack)
869 widget->core.tm.current_state = NULL((void*)0);
870 if (tm_hack &&
871 (!widget->core.tm.translations ||
872 (do_tm_hack &&
873 widget->core.tm.translations->operation != XtTableReplace0)) &&
874 XrmQGetSearchResource(searchList, QbaseTranslations,
875 QTranslations, &rawType, &value)) {
876 if (rawType != QTranslationTable) {
877 convValue.size = sizeof(XtTranslations);
878 convValue.addr = (XPointer)&widget->core.tm.current_state;
879 (void)_XtConvert(widget, rawType, &value,
880 QTranslationTable, &convValue, cache_ptr);
881 if (cache_ptr && *cache_ptr)
882 cache_ptr++;
883 } else {
884 /* value.addr can be NULL see: !already_copied */
885 if (value.addr)
886 *((XtTranslations *)&widget->core.tm.current_state) =
887 *((XtTranslations *)value.addr);
888 }
889 }
890 }
891 if ((Cardinal)num_typed_args != *pNumTypedArgs) *pNumTypedArgs = num_typed_args;
892 if (searchList != stackSearchList) XtFree((char*)searchList);
893 if (!cache_ptr)
894 cache_ptr = cache_base;
895 if (cache_ptr && cache_ptr != cache_ref) {
896 int cache_ref_size = cache_ptr - cache_ref;
897 XtCacheRef *refs = (XtCacheRef*)
898 __XtMalloc((unsigned)sizeof(XtCacheRef)*(cache_ref_size + 1));
899 (void) memmove(refs, cache_ref, sizeof(XtCacheRef)*cache_ref_size );
900 refs[cache_ref_size] = NULL((void*)0);
901 return refs;
902 }
903 return (XtCacheRef*)NULL((void*)0);
904}
905
906
907
908static void CacheArgs(
909 ArgList args,
910 Cardinal num_args,
911 XtTypedArgList typed_args,
912 Cardinal num_typed_args,
913 XrmQuarkList quark_cache,
914 Cardinal num_quarks,
915 XrmQuarkList *pQuarks) /* RETURN */
916{
917 register XrmQuarkList quarks;
918 register Cardinal i;
919 register Cardinal count;
920
921 count = (args != NULL((void*)0)) ? num_args : num_typed_args;
922
923 if (num_quarks < count) {
924 quarks = (XrmQuarkList) __XtMalloc(count * sizeof(XrmQuark));
925 } else {
926 quarks = quark_cache;
927 }
928 *pQuarks = quarks;
929
930 if (args != NULL((void*)0)) {
931 for (i = count; i; i--)
932 *quarks++ = StringToQuark((args++)->name)XrmStringToQuark((args++)->name);
933 }
934 else {
935 for (i = count; i; i--)
936 *quarks++ = StringToQuark((typed_args++)->name)XrmStringToQuark((typed_args++)->name);
937 }
938}
939
940#define FreeCache(cache, pointer)if (cache != pointer) XtFree((char *)pointer) \
941 if (cache != pointer) XtFree((char *)pointer)
942
943
944XtCacheRef *_XtGetResources(
945 register Widget w,
946 ArgList args,
947 Cardinal num_args,
948 XtTypedArgList typed_args,
949 Cardinal* num_typed_args)
950{
951 XrmName *names, names_s[50];
952 XrmClass *classes, classes_s[50];
953 XrmQuark quark_cache[100];
954 XrmQuarkList quark_args;
955 WidgetClass wc;
956 ConstraintWidgetClass cwc;
957 XtCacheRef *cache_refs, *cache_refs_core;
958 Cardinal count;
959
960 wc = XtClass(w)((w)->core.widget_class);
961
962 count = CountTreeDepth(w);
963 names = (XrmName*) XtStackAlloc (count * sizeof(XrmName), names_s)((count * sizeof(XrmName)) <= sizeof(names_s) ? (XtPointer
)(names_s) : XtMalloc((unsigned)(count * sizeof(XrmName))))
;
964 classes = (XrmClass*) XtStackAlloc (count * sizeof(XrmClass), classes_s)((count * sizeof(XrmClass)) <= sizeof(classes_s) ? (XtPointer
)(classes_s) : XtMalloc((unsigned)(count * sizeof(XrmClass)))
)
;
965 if (names == NULL((void*)0) || classes == NULL((void*)0)) _XtAllocError(NULL((void*)0));
966
967 /* Get names, classes for widget and ancestors */
968 GetNamesAndClasses(w, names, classes);
969
970 /* Compile arg list into quarks */
971 CacheArgs(args, num_args, typed_args, *num_typed_args, quark_cache,
972 XtNumber(quark_cache)((Cardinal) (sizeof(quark_cache) / sizeof(quark_cache[0]))), &quark_args);
973
974 /* Get normal resources */
975 LOCK_PROCESSif(_XtProcessLock)(*_XtProcessLock)();
976 cache_refs = GetResources(w, (char*)w, names, classes,
977 (XrmResourceList *) wc->core_class.resources,
978 wc->core_class.num_resources, quark_args, args, num_args,
979 typed_args, num_typed_args, XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited
& 0x04)
);
980
981 if (w->core.constraints != NULL((void*)0)) {
982 cwc = (ConstraintWidgetClass) XtClass(w->core.parent)((w->core.parent)->core.widget_class);
983 cache_refs_core =
984 GetResources(w, (char*)w->core.constraints, names, classes,
985 (XrmResourceList *) cwc->constraint_class.resources,
986 cwc->constraint_class.num_resources,
987 quark_args, args, num_args, typed_args, num_typed_args, False0);
988 if (cache_refs_core) {
989 XtFree((char *)cache_refs_core);
990 }
991 }
992 FreeCache(quark_cache, quark_args)if (quark_cache != quark_args) XtFree((char *)quark_args);
993 UNLOCK_PROCESSif(_XtProcessUnlock)(*_XtProcessUnlock)();
994 XtStackFree((XtPointer)names, names_s){ if (((XtPointer)names) != ((XtPointer)(names_s))) XtFree((XtPointer
)names); }
;
995 XtStackFree((XtPointer)classes, classes_s){ if (((XtPointer)classes) != ((XtPointer)(classes_s))) XtFree
((XtPointer)classes); }
;
996 return cache_refs;
997} /* _XtGetResources */
998
999
1000void _XtGetSubresources (
1001 Widget w, /* Widget "parent" of subobject */
1002 XtPointer base, /* Base address to write to */
1003 const char* name, /* name of subobject */
1004 const char* class, /* class of subobject */
1005 XtResourceList resources, /* resource list for subobject */
1006 Cardinal num_resources,
1007 ArgList args, /* arg list to override resources */
1008 Cardinal num_args,
1009 XtTypedArgList typed_args,
1010 Cardinal num_typed_args)
1011{
1012 XrmName *names, names_s[50];
1013 XrmClass *classes, classes_s[50];
1014 XrmQuark quark_cache[100];
1015 XrmQuarkList quark_args;
1016 XrmResourceList* table;
1017 Cardinal count, ntyped_args = num_typed_args;
1018 XtCacheRef *Resrc = NULL((void*)0);
1019 WIDGET_TO_APPCON(w)XtAppContext app = (w && _XtProcessLock ? XtWidgetToApplicationContext
(w) : ((void*)0))
;
1020
1021 if (num_resources == 0) return;
1
Assuming 'num_resources' is not equal to 0
2
Taking false branch
1022
1023 LOCK_APP(app)if(app && app->lock)(*app->lock)(app);
1024 count = CountTreeDepth(w);
1025 count++; /* make sure there's enough room for name and class */
1026 names = (XrmName*) XtStackAlloc(count * sizeof(XrmName), names_s)((count * sizeof(XrmName)) <= sizeof(names_s) ? (XtPointer
)(names_s) : XtMalloc((unsigned)(count * sizeof(XrmName))))
;
1027 classes = (XrmClass*) XtStackAlloc(count * sizeof(XrmClass), classes_s)((count * sizeof(XrmClass)) <= sizeof(classes_s) ? (XtPointer
)(classes_s) : XtMalloc((unsigned)(count * sizeof(XrmClass)))
)
;
1028 if (names == NULL((void*)0) || classes == NULL((void*)0)) _XtAllocError(NULL((void*)0));
3
Assuming 'names' is not equal to null
4
Assuming 'classes' is equal to null
5
Taking true branch
1029
1030 /* Get full name, class of subobject */
1031 GetNamesAndClasses(w, names, classes);
1032 count -= 2;
1033 names[count] = StringToName(name)XrmStringToQuark(name);
1034 classes[count] = StringToClass(class)XrmStringToQuark(class);
6
Array access (from variable 'classes') results in a null pointer dereference
1035 count++;
1036 names[count] = NULLQUARK((XrmQuark) 0);
1037 classes[count] = NULLQUARK((XrmQuark) 0);
1038
1039 /* Compile arg list into quarks */
1040 CacheArgs(args, num_args, typed_args, num_typed_args,
1041 quark_cache, XtNumber(quark_cache)((Cardinal) (sizeof(quark_cache) / sizeof(quark_cache[0]))), &quark_args);
1042
1043 /* Compile resource list if needed */
1044 if (((int) resources->resource_offset) >= 0) {
1045 XrmCompileResourceListEphem(resources, num_resources);
1046 }
1047 table = _XtCreateIndirectionTable(resources, num_resources);
1048 Resrc = GetResources(w, (char*)base, names, classes, table, num_resources,
1049 quark_args, args, num_args,
1050 typed_args, &ntyped_args, False0);
1051 FreeCache(quark_cache, quark_args)if (quark_cache != quark_args) XtFree((char *)quark_args);
1052 XtFree((char *)table);
1053 XtFree((char *)Resrc);
1054 XtStackFree((XtPointer)names, names_s){ if (((XtPointer)names) != ((XtPointer)(names_s))) XtFree((XtPointer
)names); }
;
1055 XtStackFree((XtPointer)classes, classes_s){ if (((XtPointer)classes) != ((XtPointer)(classes_s))) XtFree
((XtPointer)classes); }
;
1056 UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app);
1057}
1058
1059void XtGetSubresources (
1060 Widget w, /* Widget "parent" of subobject */
1061 XtPointer base, /* Base address to write to */
1062 _Xconstconst char* name, /* name of subobject */
1063 _Xconstconst char* class, /* class of subobject */
1064 XtResourceList resources, /* resource list for subobject */
1065 Cardinal num_resources,
1066 ArgList args, /* arg list to override resources */
1067 Cardinal num_args)
1068{
1069 _XtGetSubresources (w, base, name, class, resources, num_resources, args, num_args, NULL((void*)0), 0);
1070}
1071
1072
1073void _XtGetApplicationResources (
1074 Widget w, /* Application shell widget */
1075 XtPointer base, /* Base address to write to */
1076 XtResourceList resources, /* resource list for subobject */
1077 Cardinal num_resources,
1078 ArgList args, /* arg list to override resources */
1079 Cardinal num_args,
1080 XtTypedArgList typed_args,
1081 Cardinal num_typed_args)
1082{
1083 XrmName *names, names_s[50];
1084 XrmClass *classes, classes_s[50];
1085 XrmQuark quark_cache[100];
1086 XrmQuarkList quark_args;
1087 XrmResourceList* table;
1088 Cardinal count, ntyped_args = num_typed_args;
1089#ifdef XTHREADS1
1090 XtAppContext app;
1091#endif
1092 XtCacheRef *Resrc = NULL((void*)0);
1093
1094 if (num_resources == 0) return;
1095
1096#ifdef XTHREADS1
1097 if (w == NULL((void*)0)) app = _XtDefaultAppContext();
1098 else app = XtWidgetToApplicationContext(w);
1099#endif
1100
1101 LOCK_APP(app)if(app && app->lock)(*app->lock)(app);
1102 /* Get full name, class of application */
1103 if (w == NULL((void*)0)) {
1104 /* hack for R2 compatibility */
1105 XtPerDisplay pd = _XtGetPerDisplay(_XtDefaultAppContext()->list[0]);
1106 names = (XrmName*) XtStackAlloc (2 * sizeof(XrmName), names_s)((2 * sizeof(XrmName)) <= sizeof(names_s) ? (XtPointer)(names_s
) : XtMalloc((unsigned)(2 * sizeof(XrmName))))
;
1107 classes = (XrmClass*) XtStackAlloc (2 * sizeof(XrmClass), classes_s)((2 * sizeof(XrmClass)) <= sizeof(classes_s) ? (XtPointer)
(classes_s) : XtMalloc((unsigned)(2 * sizeof(XrmClass))))
;
1108 names[0] = pd->name;
1109 names[1] = NULLQUARK((XrmQuark) 0);
1110 classes[0] = pd->class;
1111 classes[1] = NULLQUARK((XrmQuark) 0);
1112 }
1113 else {
1114 count = CountTreeDepth(w);
1115 names = (XrmName*) XtStackAlloc(count * sizeof(XrmName), names_s)((count * sizeof(XrmName)) <= sizeof(names_s) ? (XtPointer
)(names_s) : XtMalloc((unsigned)(count * sizeof(XrmName))))
;
1116 classes = (XrmClass*) XtStackAlloc(count * sizeof(XrmClass), classes_s)((count * sizeof(XrmClass)) <= sizeof(classes_s) ? (XtPointer
)(classes_s) : XtMalloc((unsigned)(count * sizeof(XrmClass)))
)
;
1117 if (names == NULL((void*)0) || classes == NULL((void*)0)) _XtAllocError(NULL((void*)0));
1118 GetNamesAndClasses(w, names, classes);
1119 }
1120
1121 /* Compile arg list into quarks */
1122 CacheArgs(args, num_args, typed_args, num_typed_args, quark_cache,
1123 XtNumber(quark_cache)((Cardinal) (sizeof(quark_cache) / sizeof(quark_cache[0]))), &quark_args);
1124 /* Compile resource list if needed */
1125 if (((int) resources->resource_offset) >= 0) {
1126#ifdef CRAY2
1127 if (base == 0) { /* this client is non-portable, but... */
1128 int count;
1129 XtResourceList res = resources;
1130 for (count = 0; count < num_resources; res++, count++) {
1131 res->resource_offset *= sizeof(long);
1132 }
1133 }
1134#endif /* CRAY2 */
1135 XrmCompileResourceListEphem(resources, num_resources);
1136 }
1137 table = _XtCreateIndirectionTable(resources,num_resources);
1138
1139 Resrc = GetResources(w, (char*)base, names, classes, table, num_resources,
1140 quark_args, args, num_args,
1141 typed_args, &ntyped_args, False0);
1142 FreeCache(quark_cache, quark_args)if (quark_cache != quark_args) XtFree((char *)quark_args);
1143 XtFree((char *)table);
1144 XtFree((char *)Resrc);
1145 if (w != NULL((void*)0)) {
1146 XtStackFree((XtPointer)names, names_s){ if (((XtPointer)names) != ((XtPointer)(names_s))) XtFree((XtPointer
)names); }
;
1147 XtStackFree((XtPointer)classes, classes_s){ if (((XtPointer)classes) != ((XtPointer)(classes_s))) XtFree
((XtPointer)classes); }
;
1148 }
1149 UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app);
1150}
1151
1152void XtGetApplicationResources (
1153 Widget w, /* Application shell widget */
1154 XtPointer base, /* Base address to write to */
1155 XtResourceList resources, /* resource list for subobject */
1156 Cardinal num_resources,
1157 ArgList args, /* arg list to override resources */
1158 Cardinal num_args)
1159{
1160 _XtGetApplicationResources(w, base, resources, num_resources, args, num_args, NULL((void*)0), 0);
1161}
1162
1163static Boolean initialized = FALSE0;
1164
1165void _XtResourceListInitialize(void)
1166{
1167 LOCK_PROCESSif(_XtProcessLock)(*_XtProcessLock)();
1168 if (initialized) {
1169 XtWarningMsg("initializationError","xtInitialize",XtCXtToolkitError,
1170 "Initializing Resource Lists twice",
1171 (String *)NULL((void*)0), (Cardinal *)NULL((void*)0));
1172 UNLOCK_PROCESSif(_XtProcessUnlock)(*_XtProcessUnlock)();
1173 return;
1174 }
1175 initialized = TRUE1;
1176 UNLOCK_PROCESSif(_XtProcessUnlock)(*_XtProcessUnlock)();
1177
1178 QBoolean = XrmPermStringToQuark(XtCBoolean((char*)&XtStrings[920]));
1179 QString = XrmPermStringToQuark(XtCString((char*)&XtStrings[1416]));
1180 QCallProc = XrmPermStringToQuark(XtRCallProc((char*)&XtStrings[1578]));
1181 QImmediate = XrmPermStringToQuark(XtRImmediate((char*)&XtStrings[1695]));
1182 QinitialResourcesPersistent = XrmPermStringToQuark(XtNinitialResourcesPersistent((char*)&XtStrings[264]));
1183 QInitialResourcesPersistent = XrmPermStringToQuark(XtCInitialResourcesPersistent((char*)&XtStrings[1071]));
1184 Qtranslations = XrmPermStringToQuark(XtNtranslations((char*)&XtStrings[802]));
1185 QbaseTranslations = XrmPermStringToQuark("baseTranslations");
1186 QTranslations = XrmPermStringToQuark(XtCTranslations((char*)&XtStrings[1484]));
1187 QTranslationTable = XrmPermStringToQuark(XtRTranslationTable((char*)&XtStrings[1841]));
1188 Qscreen = XrmPermStringToQuark(XtNscreen((char*)&XtStrings[584]));
1189 QScreen = XrmPermStringToQuark(XtCScreen((char*)&XtStrings[1273]));
1190}