mpi module plugged.
[scilab.git] / scilab / modules / mpi / src / c / serialization.c
index 664a9b9..ce1cfbc 100644 (file)
@@ -6,15 +6,16 @@
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
  * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
  *
  */
 #include <string.h>
 #include <stdio.h>
 #include "api_scilab.h"
 #include "BOOL.h"
-#include "MALLOC.h"
+#include "sci_malloc.h"
 #include "serialization.h"
+#include "elem_common.h"
 
 static int serialize_double(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
@@ -430,28 +431,36 @@ static int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_p
 
 int serialize_to_mpi(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
-    switch (*_piAddr)
+    int iType = 0;
+    SciErr sciErr = getVarType(_pvCtx, _piAddr, &iType);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    switch (iType)
     {
         case sci_matrix:
-            return serialize_double(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_double(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         case sci_strings:
-            return serialize_string(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_string(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         case sci_boolean:
-            return serialize_boolean(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_boolean(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         case sci_sparse:
-            return serialize_sparse(pvApiCtx, _piAddr, _piBuffer, _piBufferSize, TRUE);
+            return serialize_sparse(_pvCtx, _piAddr, _piBuffer, _piBufferSize, TRUE);
             break;
         case sci_boolean_sparse:
-            return serialize_sparse(pvApiCtx, _piAddr, _piBuffer, _piBufferSize, FALSE);
+            return serialize_sparse(_pvCtx, _piAddr, _piBuffer, _piBufferSize, FALSE);
             break;
         case sci_ints:
-            return serialize_int(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_int(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         default:
             return -1;
             break;
     }
-}
\ No newline at end of file
+}