Author: astitcher
Date: Wed Dec  5 21:30:47 2012
New Revision: 1417656

URL: http://svn.apache.org/viewvc?rev=1417656&view=rev
Log:
NO-JIRA: More portability work (FreeBSD, Solaris, mingw32)
- Fixed a memory leak on FreeBSD
- Added simple UUID generator for Win32 and checks for it
- Removed use of uuid_unparse_lower() which doesn't exist on Solaris
- Removed use of GNU_SOURCE define instead didn't require ANSI C on
  non engine code

Modified:
    qpid/proton/trunk/proton-c/CMakeLists.txt
    qpid/proton/trunk/proton-c/src/codec/codec.c
    qpid/proton/trunk/proton-c/src/platform.c
    qpid/proton/trunk/proton-c/src/proton.c

Modified: qpid/proton/trunk/proton-c/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/CMakeLists.txt?rev=1417656&r1=1417655&r2=1417656&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/CMakeLists.txt Wed Dec  5 21:30:47 2012
@@ -127,7 +127,12 @@ else (UUID_GENERATE_IN_LIBC)
     if (UUID_CREATE_IN_LIBC)
       list(APPEND PLATFORM_DEFINITIONS "USE_UUID_CREATE")
     else (UUID_CREATE_IN_LIBC)
-      message(FATAL_ERROR "neither uuid_generate() nor uuid_create() found")
+      CHECK_SYMBOL_EXISTS(UuidToString "rpc.h" WIN_UUID)
+      if (WIN_UUID)
+        list(APPEND PLATFORM_DEFINITIONS "USE_WIN_UUID")
+      else (WIN_UUID)
+        message(FATAL_ERROR "No Uuid API found")
+      endif (WIN_UUID)
     endif (UUID_CREATE_IN_LIBC)
   endif (UUID_GENERATE_IN_UUID)
 endif (UUID_GENERATE_IN_LIBC)
@@ -247,7 +252,7 @@ target_link_libraries (proton-dump qpid-
 set_target_properties (
     proton proton-dump
     PROPERTIES
-    COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS}"
+    COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_PLATFORM_FLAGS}"
 )
 
 # Install executables and libraries

Modified: qpid/proton/trunk/proton-c/src/codec/codec.c
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/codec/codec.c?rev=1417656&r1=1417655&r2=1417656&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/codec/codec.c (original)
+++ qpid/proton/trunk/proton-c/src/codec/codec.c Wed Dec  5 21:30:47 2012
@@ -19,8 +19,6 @@
  *
  */
 
-#define _GNU_SOURCE
-
 #include <proton/codec.h>
 #include <proton/error.h>
 #include <proton/buffer.h>

Modified: qpid/proton/trunk/proton-c/src/platform.c
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/platform.c?rev=1417656&r1=1417655&r2=1417656&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/platform.c (original)
+++ qpid/proton/trunk/proton-c/src/platform.c Wed Dec  5 21:30:47 2012
@@ -49,7 +49,7 @@ char* pn_i_genuuid(void) {
     char *generated = malloc(37*sizeof(char));
     uuid_t uuid;
     uuid_generate(uuid);
-    uuid_unparse_lower(uuid, generated);
+    uuid_unparse(uuid, generated);
     return generated;
 }
 #elif USE_UUID_CREATE
@@ -59,8 +59,20 @@ char* pn_i_genuuid(void) {
     uuid_t uuid;
     uint32_t rc;
     uuid_create(&uuid, &rc);
+    // Under FreeBSD the returned string is newly allocated from the heap
     uuid_to_string(&uuid, &generated, &rc);
-    return pn_strdup(generated);
+    return generated;
+}
+#elif USE_WIN_UUID
+#include <rpc.h>
+char* pn_i_genuuid(void) {
+    RPC_CSTR generated;
+    UUID uuid;
+    UuidCreate(&uuid);
+    UuidToString(&uuid, &generated);
+    char* r = pn_strdup((const char*)generated);
+    RpcStringFree(&generated);
+    return r;
 }
 #else
 #error "Don't know how to generate uuid strings on this platform"

Modified: qpid/proton/trunk/proton-c/src/proton.c
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/proton.c?rev=1417656&r1=1417655&r2=1417656&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/proton.c (original)
+++ qpid/proton/trunk/proton-c/src/proton.c Wed Dec  5 21:30:47 2012
@@ -19,8 +19,6 @@
  *
  */
 
-#define _GNU_SOURCE
-
 #include <stdio.h>
 #include <string.h>
 #include <proton/driver.h>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to