#include "Desk.KernelSWIs.h"
#include "Desk.SWI.h"
#include "Desk.DeskMem.h"
#include "Desk.Debug.h"
#include "Desk.Error2.h"


char	*Desk_OS_ReadVarVal_AutoAlloc( const char *varname)
{
int	len;
char	*buffer;

Desk_Debug4_Printf( Desk_error_PLACE "Desk_OS_ReadVarVal_AutoAlloc called for '%s'\n", varname);

len = Desk_OS_ReadVarVal_GetLength( varname);

Desk_Debug5_Printf( Desk_error_PLACE "Desk_OS_ReadVarVal_GetLength returned %i\n", len);

Desk_Debug_Assert( len>=0);

Desk_Debug5_Printf( Desk_error_PLACE "Calling Desk_DeskMem_Malloc...\n");
buffer = Desk_DeskMem_Malloc( 1+len);
Desk_Debug5_Printf( Desk_error_PLACE "buffer=0x%p\n", buffer);

Desk_OS_ReadVarVal_ReadIntoBuffer( buffer, varname, 1+len);

Desk_Debug_Printf( Desk_error_PLACE "Desk_OS_ReadVarVal_AutoAlloc returning '%s'\n", buffer);

return buffer;
}
