/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* typval.c: functions that deal with a typval
*/
#include "vim.h"
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Allocate memory for a variable type-value, and make it empty (0 or NULL
* value).
*/
typval_T *
alloc_tv(void)
{
return ALLOC_CLEAR_ONE(typval_T);
}
/*
* Allocate memory for a variable type-value, and assign a string to it.
* The string "s" must have been allocated, it is consumed.
* Return NULL for out of memory, the variable otherwise.
*/
typval_T *
alloc_string_tv(char_u *s)
{
typval_T *rettv;
rettv = alloc_tv();
if (rettv != NULL)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = s;
}
else
vim_free(s);
return rettv;
}
/*
* Free the memory for a variable type-value.
*/
void
free_tv(