lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #include "uemf.h" |
| 2 | |
| 3 | value_t valueString(char_t* value, int flags) |
| 4 | { |
| 5 | value_t v; |
| 6 | |
| 7 | memset(&v, 0x0, sizeof(v)); |
| 8 | v.valid = 1; |
| 9 | v.type = string; |
| 10 | if (flags & VALUE_ALLOCATE) { |
| 11 | v.allocated = 1; |
| 12 | v.value.string = gstrdup(B_L, value); |
| 13 | } else { |
| 14 | v.allocated = 0; |
| 15 | v.value.string = value; |
| 16 | } |
| 17 | return v; |
| 18 | } |
| 19 | |
| 20 | value_t valueInteger(long value) |
| 21 | { |
| 22 | value_t v; |
| 23 | |
| 24 | memset(&v, 0x0, sizeof(v)); |
| 25 | v.valid = 1; |
| 26 | v.type = integer; |
| 27 | v.value.integer = value; |
| 28 | return v; |
| 29 | } |
| 30 | |
| 31 | void valueFree(value_t* v) |
| 32 | { |
| 33 | if (v->valid && v->allocated && v->type == string && |
| 34 | v->value.string != NULL) { |
| 35 | bfree(B_L, v->value.string); |
| 36 | } |
| 37 | v->type = undefined; |
| 38 | v->valid = 0; |
| 39 | v->allocated = 0; |
| 40 | } |
| 41 | |