layers: Eliminate const_cast in safe_struct string

diff --git a/layers/generated/vk_safe_struct.cpp b/layers/generated/vk_safe_struct.cpp
index 147484f..3b95490 100644
--- a/layers/generated/vk_safe_struct.cpp
+++ b/layers/generated/vk_safe_struct.cpp
@@ -120,14 +120,16 @@
     enabledExtensionCount(in_struct->enabledExtensionCount)
 {
     pNext = SafePnextCopy(in_struct->pNext);
-    ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (in_struct->pApplicationInfo)
         pApplicationInfo = new safe_VkApplicationInfo(in_struct->pApplicationInfo);
     else
@@ -147,14 +149,16 @@
     enabledLayerCount = src.enabledLayerCount;
     enabledExtensionCount = src.enabledExtensionCount;
     pNext = SafePnextCopy(src.pNext);
-    ppEnabledLayerNames = new char *[src.enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[src.enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (src.pApplicationInfo)
         pApplicationInfo = new safe_VkApplicationInfo(*src.pApplicationInfo);
     else
@@ -187,14 +191,16 @@
     enabledLayerCount = src.enabledLayerCount;
     enabledExtensionCount = src.enabledExtensionCount;
     pNext = SafePnextCopy(src.pNext);
-    ppEnabledLayerNames = new char *[src.enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[src.enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (src.pApplicationInfo)
         pApplicationInfo = new safe_VkApplicationInfo(*src.pApplicationInfo);
     else
@@ -230,14 +236,16 @@
     enabledLayerCount = in_struct->enabledLayerCount;
     enabledExtensionCount = in_struct->enabledExtensionCount;
     pNext = SafePnextCopy(in_struct->pNext);
-    ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (in_struct->pApplicationInfo)
         pApplicationInfo = new safe_VkApplicationInfo(in_struct->pApplicationInfo);
     else
@@ -251,14 +259,16 @@
     enabledLayerCount = src->enabledLayerCount;
     enabledExtensionCount = src->enabledExtensionCount;
     pNext = SafePnextCopy(src->pNext);
-    ppEnabledLayerNames = new char *[src->enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[src->enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(src->ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(src->ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[src->enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[src->enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(src->ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(src->ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (src->pApplicationInfo)
         pApplicationInfo = new safe_VkApplicationInfo(*src->pApplicationInfo);
     else
@@ -430,14 +440,16 @@
     pEnabledFeatures(nullptr)
 {
     pNext = SafePnextCopy(in_struct->pNext);
-    ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (queueCreateInfoCount && in_struct->pQueueCreateInfos) {
         pQueueCreateInfos = new safe_VkDeviceQueueCreateInfo[queueCreateInfoCount];
         for (uint32_t i = 0; i < queueCreateInfoCount; ++i) {
@@ -467,14 +479,16 @@
     enabledExtensionCount = src.enabledExtensionCount;
     pEnabledFeatures = nullptr;
     pNext = SafePnextCopy(src.pNext);
-    ppEnabledLayerNames = new char *[src.enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[src.enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (queueCreateInfoCount && src.pQueueCreateInfos) {
         pQueueCreateInfos = new safe_VkDeviceQueueCreateInfo[queueCreateInfoCount];
         for (uint32_t i = 0; i < queueCreateInfoCount; ++i) {
@@ -517,14 +531,16 @@
     enabledExtensionCount = src.enabledExtensionCount;
     pEnabledFeatures = nullptr;
     pNext = SafePnextCopy(src.pNext);
-    ppEnabledLayerNames = new char *[src.enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[src.enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(src.ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[src.enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(src.ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (queueCreateInfoCount && src.pQueueCreateInfos) {
         pQueueCreateInfos = new safe_VkDeviceQueueCreateInfo[queueCreateInfoCount];
         for (uint32_t i = 0; i < queueCreateInfoCount; ++i) {
@@ -570,14 +586,16 @@
     enabledExtensionCount = in_struct->enabledExtensionCount;
     pEnabledFeatures = nullptr;
     pNext = SafePnextCopy(in_struct->pNext);
-    ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[in_struct->enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(in_struct->ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[in_struct->enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(in_struct->ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (queueCreateInfoCount && in_struct->pQueueCreateInfos) {
         pQueueCreateInfos = new safe_VkDeviceQueueCreateInfo[queueCreateInfoCount];
         for (uint32_t i = 0; i < queueCreateInfoCount; ++i) {
@@ -599,14 +617,16 @@
     enabledExtensionCount = src->enabledExtensionCount;
     pEnabledFeatures = nullptr;
     pNext = SafePnextCopy(src->pNext);
-    ppEnabledLayerNames = new char *[src->enabledLayerCount];
+    char **tmp_ppEnabledLayerNames = new char *[src->enabledLayerCount];
     for (uint32_t i = 0; i < enabledLayerCount; ++i) {
-        (const_cast<const char **>(ppEnabledLayerNames))[i] = SafeStringCopy(src->ppEnabledLayerNames[i]);
+        tmp_ppEnabledLayerNames[i] = SafeStringCopy(src->ppEnabledLayerNames[i]);
     }
-    ppEnabledExtensionNames = new char *[src->enabledExtensionCount];
+    ppEnabledLayerNames = tmp_ppEnabledLayerNames;
+    char **tmp_ppEnabledExtensionNames = new char *[src->enabledExtensionCount];
     for (uint32_t i = 0; i < enabledExtensionCount; ++i) {
-        (const_cast<const char **>(ppEnabledExtensionNames))[i] = SafeStringCopy(src->ppEnabledExtensionNames[i]);
+        tmp_ppEnabledExtensionNames[i] = SafeStringCopy(src->ppEnabledExtensionNames[i]);
     }
+    ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
     if (queueCreateInfoCount && src->pQueueCreateInfos) {
         pQueueCreateInfos = new safe_VkDeviceQueueCreateInfo[queueCreateInfoCount];
         for (uint32_t i = 0; i < queueCreateInfoCount; ++i) {
@@ -28299,7 +28319,7 @@
     pNext = SafePnextCopy(src->pNext);
 }
 
-const char *SafeStringCopy(const char *in_string) {
+char *SafeStringCopy(const char *in_string) {
     if (nullptr == in_string) return nullptr;
     char* dest = new char[std::strlen(in_string) + 1];
     return std::strcpy(dest, in_string);
diff --git a/layers/generated/vk_safe_struct.h b/layers/generated/vk_safe_struct.h
index f3e35f4..6a88318 100644
--- a/layers/generated/vk_safe_struct.h
+++ b/layers/generated/vk_safe_struct.h
@@ -37,7 +37,7 @@
 void *SafePnextCopy(const void *pNext);
 void FreePnextChain(const void *head);
 void FreePnextChain(void *head);
-const char *SafeStringCopy(const char *in_string);
+char *SafeStringCopy(const char *in_string);
 
 
 struct safe_VkApplicationInfo {
diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py
index 288cc0c..638a517 100644
--- a/scripts/helper_file_generator.py
+++ b/scripts/helper_file_generator.py
@@ -460,7 +460,7 @@
         safe_struct_helper_header += 'void *SafePnextCopy(const void *pNext);\n'
         safe_struct_helper_header += 'void FreePnextChain(const void *head);\n'
         safe_struct_helper_header += 'void FreePnextChain(void *head);\n'
-        safe_struct_helper_header += 'const char *SafeStringCopy(const char *in_string);\n'
+        safe_struct_helper_header += 'char *SafeStringCopy(const char *in_string);\n'
         safe_struct_helper_header += '\n'
         safe_struct_helper_header += self.GenerateSafeStructHeader()
         return safe_struct_helper_header
@@ -877,7 +877,7 @@
         # Construct Safe-struct helper functions
 
         string_copy_proc = '\n\n'
-        string_copy_proc += 'const char *SafeStringCopy(const char *in_string) {\n'
+        string_copy_proc += 'char *SafeStringCopy(const char *in_string) {\n'
         string_copy_proc += '    if (nullptr == in_string) return nullptr;\n'
         string_copy_proc += '    char* dest = new char[std::strlen(in_string) + 1];\n'
         string_copy_proc += '    return std::strcpy(dest, in_string);\n'
@@ -1250,10 +1250,11 @@
                             if m_type == 'char':
                                 # Create deep copies of strings
                                 if member.len:
-                                    copy_strings += '    %s = new char *[in_struct->%s];\n' % (member.name, member.len)
+                                    copy_strings += '    char **tmp_%s = new char *[in_struct->%s];\n' % (member.name, member.len)
                                     copy_strings += '    for (uint32_t i = 0; i < %s; ++i) {\n' % member.len
-                                    copy_strings += '        (const_cast<const char **>(%s))[i] = SafeStringCopy(in_struct->%s[i]);\n' % (member.name, member.name)
+                                    copy_strings += '        tmp_%s[i] = SafeStringCopy(in_struct->%s[i]);\n' % (member.name, member.name)
                                     copy_strings += '    }\n'
+                                    copy_strings += '    %s = tmp_%s;\n' % (member.name, member.name)
 
                                     destruct_txt += '    if (%s) {\n' % member.name
                                     destruct_txt += '        for (uint32_t i = 0; i < %s; ++i) {\n' % member.len