factor/vm/utilities.cpp

29 lines
525 B
C++
Raw Normal View History

2009-05-02 05:04:19 -04:00
#include "master.hpp"
2009-05-04 02:46:13 -04:00
namespace factor
{
2009-05-02 05:04:19 -04:00
/* If memory allocation fails, bail out */
vm_char *safe_strdup(const vm_char *str)
2009-05-02 05:04:19 -04:00
{
2009-05-04 05:50:24 -04:00
vm_char *ptr = STRDUP(str);
2009-05-02 05:04:19 -04:00
if(!ptr) fatal_error("Out of memory in safe_strdup", 0);
return ptr;
}
cell read_cell_hex()
2009-05-02 05:04:19 -04:00
{
2009-05-04 05:50:24 -04:00
cell cell;
2009-05-13 02:08:16 -04:00
if(scanf(CELL_HEX_FORMAT,&cell) < 0) exit(1);
2009-05-02 05:04:19 -04:00
return cell;
2009-08-17 16:37:09 -04:00
}
2010-01-07 01:31:15 -05:00
/* On Windows, memcpy() is in a different DLL and the non-optimizing
compiler can't find it */
VM_C_API void *factor_memcpy(void *dst, void *src, size_t len)
{
return memcpy(dst,src,len);
}
2009-05-04 02:46:13 -04:00
}