Assign a string value to a variable, creating it if need be */ Returns false on failure (bad name) */
| 1647 | /* Assign a string value to a variable, creating it if need be */ |
| 1648 | /* Returns false on failure (bad name) */ |
| 1649 | static bool |
| 1650 | putVariable(CState *st, const char *context, char *name, const char *value) |
| 1651 | { |
| 1652 | Variable *var; |
| 1653 | char *val; |
| 1654 | |
| 1655 | var = lookupCreateVariable(st, context, name); |
| 1656 | if (!var) |
| 1657 | return false; |
| 1658 | |
| 1659 | /* dup then free, in case value is pointing at this variable */ |
| 1660 | val = pg_strdup(value); |
| 1661 | |
| 1662 | if (var->svalue) |
| 1663 | free(var->svalue); |
| 1664 | var->svalue = val; |
| 1665 | var->value.type = PGBT_NO_VALUE; |
| 1666 | |
| 1667 | return true; |
| 1668 | } |
| 1669 | |
| 1670 | /* Assign a value to a variable, creating it if need be */ |
| 1671 | /* Returns false on failure (bad name) */ |
no test coverage detected