OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [libnetworking/] [rtems_webserver/] [value.c] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 158 chris
/*
2
 * value.c -- Generic type (holds all types)
3
 *
4
 * Copyright (c) Go Ahead Software, Inc., 1995-1999
5
 *
6
 * See the file "license.txt" for usage and redistribution license requirements
7
 */
8
 
9
/******************************** Description *********************************/
10
 
11
/*
12
 *      This module provides a generic type that can hold all possible types.
13
 *      It is designed to provide maximum effeciency.
14
 */
15
 
16
/********************************* Includes ***********************************/
17
 
18
#include        "uemf.h"
19
 
20
/*********************************** Locals ***********************************/
21
 
22
 
23
/*********************************** Code *************************************/
24
/*
25
 *      Initialize a integer value.
26
 */
27
 
28
value_t valueInteger(long value)
29
{
30
        value_t v = VALUE_VALID;
31
 
32
        v.value.integer = value;
33
        return v;
34
}
35
 
36
/******************************************************************************/
37
/*
38
 *      Initialize a string value. Note: not allocation
39
 */
40
 
41
value_t valueString(char_t *value, int flags)
42
{
43
        value_t v = VALUE_VALID;
44
 
45
        v.type = string;
46
        if (flags & VALUE_ALLOCATE) {
47
                v.allocated = 1;
48
                v.value.string = gstrdup(B_L, value);
49
        } else {
50
                v.allocated = 0;
51
                v.value.string = value;
52
        }
53
        return v;
54
}
55
 
56
/******************************************************************************/
57
/*
58
 *      Free any storage allocated for a value.
59
 */
60
 
61
void valueFree(value_t *v)
62
{
63
        a_assert(v);
64
 
65
        if (v->valid && v->allocated && v->type == string &&
66
                        v->value.string != NULL) {
67
                bfree(B_L, v->value.string);
68
        }
69
        v->type = undefined;
70
        v->valid = 0;
71
        v->allocated = 0;
72
}
73
 
74
/******************************************************************************/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.