offload_host.cpp (OffloadDescriptor::setup_misc_data): Use calloc instead of malloc.
authorIlya Verbin <ilya.verbin@intel.com>
Mon, 26 Oct 2015 14:38:02 +0000 (14:38 +0000)
committerIlya Verbin <iverbin@gcc.gnu.org>
Mon, 26 Oct 2015 14:38:02 +0000 (14:38 +0000)
liboffloadmic/
* runtime/offload_host.cpp (OffloadDescriptor::setup_misc_data): Use
calloc instead of malloc.
(__offload_fini_library): Set mic_engines_total to zero.

Co-Authored-By: Aleksander Ivanushenko <aleksander.ivanushenko@intel.com>
From-SVN: r229368

liboffloadmic/ChangeLog
liboffloadmic/runtime/offload_host.cpp

index 82e7999188c97a270a17a4ef615c03d698eaef50..93419bdfaaf06ad31a32f7158be4e55f71834dc4 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-26  Ilya Verbin  <ilya.verbin@intel.com>
+           Aleksander Ivanushenko  <aleksander.ivanushenko@intel.com>
+
+       * runtime/offload_host.cpp (OffloadDescriptor::setup_misc_data): Use
+       calloc instead of malloc.
+       (__offload_fini_library): Set mic_engines_total to zero.
+
 2015-10-13  Ilya Verbin  <ilya.verbin@intel.com>
 
        * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_dev2dev): New
index eec457d386a8023bce909d02d781f58697da780e..c10dc4efb550cca5c65f34702b066b0dea6a32a0 100644 (file)
@@ -2421,8 +2421,8 @@ bool OffloadDescriptor::setup_misc_data(const char *name)
         }
 
         // initialize function descriptor
-        m_func_desc = (FunctionDescriptor*) malloc(m_func_desc_size +
-                                                   misc_data_size);
+        m_func_desc = (FunctionDescriptor*) calloc(1, m_func_desc_size
+                                                     + misc_data_size);
         if (m_func_desc == NULL)
           LIBOFFLOAD_ERROR(c_malloc);
         m_func_desc->console_enabled = console_enabled;
@@ -5087,6 +5087,7 @@ static void __offload_fini_library(void)
     OFFLOAD_DEBUG_TRACE(2, "Cleanup offload library ...\n");
     if (mic_engines_total > 0) {
         delete[] mic_engines;
+        mic_engines_total = 0;
 
         if (mic_proxy_fs_root != 0) {
             free(mic_proxy_fs_root);