diff --git a/glsl2spv.cpp b/glsl2spv.cpp index 77535df..5a2d13b 100644 --- a/glsl2spv.cpp +++ b/glsl2spv.cpp @@ -251,6 +251,17 @@ extern "C" return VertexAttribBaseType::MAX; } + + char *new_strcpy(const char *src) + { + int len=1+strlen(src); + + char *str=new char[len]; + + memcpy(str,src,len); + + return str; + } struct ShaderStage { @@ -288,8 +299,7 @@ extern "C" { uint8_t input_attachment_index; }; - }; - + }; }; struct ShaderResourceData @@ -315,13 +325,7 @@ extern "C" void Init() { - memset(&input,0,sizeof(ShaderStageData)); - memset(&output,0,sizeof(ShaderStageData)); - - memset(&resource,0,sizeof(resource)); - - memset(&push_constant,0,sizeof(ShaderResourceData)); - memset(&subpass_input,0,sizeof(ShaderResourceData)); + memset(this,0,sizeof(SPVData)); } void Clear() @@ -340,22 +344,18 @@ extern "C" SPVData(const char *l,const char *dl) { + Init(); + result=false; - log=new char[strlen(l)+1]; - strcpy(log,l); - - debug_log=new char[strlen(dl)+1]; - strcpy(debug_log,dl); + log=new_strcpy(l); + debug_log=new_strcpy(dl); spv_data=nullptr; - - Init(); } SPVData(const char* log) : SPVData(log, log) { - } SPVData(const std::vector &spirv)