#include #include "honeysuckle.h" void hs_throw_error(lua_State *L, const char *format_string, ...) { va_list args, args_; va_start(args, format_string); va_copy(args_, args); int string_size = vsnprintf(NULL, 0, format_string, args_); va_end(args_); char *string = malloc((string_size+1) * sizeof(char)); if (string == NULL) lua_pushstring(L, "there was an error allocating memory for an error message"); else { vsnprintf(string, string_size+1, format_string, args); lua_pushstring(L, string); free(string); } lua_error(L); }