Browse Source

partial revert of the PR #260, the memory allocators can be safely defined before including our header files

Stasik0 9 years ago
parent
commit
e62e5a409f
2 changed files with 11 additions and 20 deletions
  1. 0 10
      src/client/ua_client.c
  2. 11 10
      src/ua_util.h

+ 0 - 10
src/client/ua_client.c

@@ -467,16 +467,6 @@ UA_StatusCode UA_Client_connect(UA_Client *client, UA_ConnectClientConnection co
     if(retval == UA_STATUSCODE_GOOD)
         retval = ActivateSession(client);
         
-    #ifdef MATLAB_MEX_FILE
-	if(retval == UA_STATUSCODE_GOOD){
-	    mexMakeMemoryPersistent(client);    
-	    mexMakeMemoryPersistent(&client->connection);
-	    mexMakeMemoryPersistent(client->endpointUrl.data);
-	    mexMakeMemoryPersistent(client->clientNonce.data);
-	    mexMakeMemoryPersistent(client->serverNonce.data);
-	}
-    #endif
-        
     return retval;
 }
 

+ 11 - 10
src/ua_util.h

@@ -49,16 +49,17 @@
 #define UA_assert(ignore) assert(ignore)
 
 /* Replace the macros with functions for custom allocators if necessary */
-#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
-#define UA_free(ptr) mxFree(ptr)
-#define UA_malloc(size) mxMalloc(size)
-#define UA_calloc(num, size) mxCalloc(num, size)
-#define UA_realloc(ptr, size) mxRealloc(ptr, size)
-#else
-#define UA_free(ptr) free(ptr)
-#define UA_malloc(size) malloc(size)
-#define UA_calloc(num, size) calloc(num, size)
-#define UA_realloc(ptr, size) realloc(ptr, size)
+#ifndef UA_free
+    #define UA_free(ptr) free(ptr)
+#endif
+#ifndef UA_free
+    #define UA_malloc(size) malloc(size)
+#endif
+#ifndef UA_calloc
+    #define UA_calloc(num, size) calloc(num, size)
+#endif
+#ifndef UA_realloc
+    #define UA_realloc(ptr, size) realloc(ptr, size)
 #endif
 
 #define UA_memcpy(dst, src, size) memcpy(dst, src, size)