File: VAllocColor.c

package info (click to toggle)
acm4 4.7-18
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,776 kB
  • ctags: 1,621
  • sloc: ansic: 16,777; makefile: 364; sh: 31
file content (51 lines) | stat: -rw-r--r-- 885 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Vlib.h"
#include <string.h>

VColor *
VAllocColor (name)
char *name;
{
	return VAllocDepthCueuedColor (name, 0);
}


VColor *
VAllocDepthCueuedColor (name, flag)
char	*name;
int	flag;
{

	VColor	*p=_VDefaultWorkContext->VColorList, *prev=0, **q;

/*
 *  Search for this color among those already allocated.
 */

	while (p != (VColor *) 0) {
		if (strcmp(p->color_name, name) == 0) {
			if ((flag && (p->flags & ColorEnableDepthCueing)) ||
				(flag == 0 && p->flags == 0)) {
				return p;
			}
		}
		prev = p;
		p = p->next;
	}

/*
 *  The color was not in the list; allocate a new list element.
 */

	if (prev == (VColor *)0)
		q = &_VDefaultWorkContext->VColorList;
	else
		q = &(prev->next);

	*q = (VColor *) Vmalloc (sizeof(VColor));
	(*q)->color_name = strdup (name);
	(*q)->cIndex = 0;
	(*q)->flags = flag ? ColorEnableDepthCueing : 0;
	(*q)->next = 0;

	return *q;
}