Replace some unsafe API calls with safe alternatives on Windows, prepare code for similar actions on other platforms - wrap unsafe API calls into macros.

llvm-svn: 233915
diff --git a/openmp/runtime/src/kmp_str.c b/openmp/runtime/src/kmp_str.c
index 06ec7f2..0bcd40c 100644
--- a/openmp/runtime/src/kmp_str.c
+++ b/openmp/runtime/src/kmp_str.c
@@ -112,7 +112,7 @@
             if ( buffer->str == NULL ) {
 		KMP_FATAL( MemoryAllocFailed );
             }; // if
-            memcpy( buffer->str, buffer->bulk, buffer->used + 1 );
+            KMP_MEMCPY_S( buffer->str, buffer->size, buffer->bulk, buffer->used + 1 );
         } else {
             buffer->str = (char *) KMP_INTERNAL_REALLOC( buffer->str, buffer->size );
             if ( buffer->str == NULL ) {
@@ -142,7 +142,7 @@
         if ( buffer->str == NULL ) {
 		KMP_FATAL( MemoryAllocFailed );
         }; // if
-        memcpy( buffer->str, buffer->bulk, buffer->used + 1 );
+        KMP_MEMCPY_S( buffer->str, buffer->size, buffer->bulk, buffer->used + 1 );
     }; // if
 
 } // __kmp_str_buf_detach
@@ -173,7 +173,7 @@
     KMP_DEBUG_ASSERT( str != NULL );
     KMP_DEBUG_ASSERT( len >= 0 );
     __kmp_str_buf_reserve( buffer, buffer->used + len + 1 );
-    memcpy( buffer->str + buffer->used, str, len );
+    KMP_MEMCPY( buffer->str + buffer->used, str, len );
     buffer->str[ buffer->used + len ] = 0;
     buffer->used += len;
     KMP_STR_BUF_INVARIANT( buffer );
@@ -211,7 +211,7 @@
                 __va_copy( _args, args );  // Make copy of args.
                 #define args _args         // Substitute args with its copy, _args.
             #endif // KMP_OS_WINDOWS
-            rc = vsnprintf( buffer->str + buffer->used, free, format, args );
+            rc = KMP_VSNPRINTF( buffer->str + buffer->used, free, format, args );
             #if ! KMP_OS_WINDOWS
                 #undef args                // Remove substitution.
                 va_end( _args );
@@ -502,7 +502,7 @@
 
         // Try to format string.
         va_start( args, format );
-        rc = vsnprintf( buffer, size, format, args );
+        rc = KMP_VSNPRINTF( buffer, size, format, args );
         va_end( args );
 
         // No errors, string has been formatted.