fix uuid generation for android
authorHussein Kasem <huss@pep-project.org>
Wed, 19 Oct 2016 18:36:05 +0200
changeset 131872e7ce41cce0
parent 1317 0e6df10f76c4
child 1319 914e58c5e508
fix uuid generation for android
src/platform_unix.c
     1.1 --- a/src/platform_unix.c	Wed Oct 19 08:34:23 2016 +0200
     1.2 +++ b/src/platform_unix.c	Wed Oct 19 18:36:05 2016 +0200
     1.3 @@ -117,15 +117,17 @@
     1.4      return buffer;
     1.5  }
     1.6  
     1.7 -// TODO: Check and possibly fix this function if necessary
     1.8 +
     1.9  void uuid_generate_random(pEpUUID out)
    1.10  {
    1.11      uuid_t *uuid;
    1.12      uuid_rc_t rc_create;
    1.13 -
    1.14 +    size_t size = sizeof(uuid_string_t);
    1.15 +    void *_out = out;
    1.16 +	
    1.17      if ((rc_create = uuid_create(&uuid)) != UUID_RC_OK ||
    1.18          uuid_make(uuid, UUID_MAKE_V1) != UUID_RC_OK ||
    1.19 -        uuid_export(uuid, UUID_FMT_BIN, out, NULL) != UUID_RC_OK)
    1.20 +        uuid_export(uuid, UUID_FMT_BIN, &_out, &size) != UUID_RC_OK)
    1.21      {
    1.22          memset(out, 0, sizeof(pEpUUID));
    1.23      }
    1.24 @@ -136,15 +138,17 @@
    1.25      }
    1.26  }
    1.27  
    1.28 -// TODO: Check and possibly fix this function if necessary
    1.29 +
    1.30  void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
    1.31  {
    1.32      uuid_t *uuid;
    1.33      uuid_rc_t rc_create;
    1.34 +    size_t size = sizeof(uuid_string_t);
    1.35 +    void *_out = out;
    1.36  
    1.37      if ((rc_create = uuid_create(&uuid)) != UUID_RC_OK ||
    1.38          uuid_import(uuid, UUID_FMT_BIN, uu, sizeof(pEpUUID)) != UUID_RC_OK ||
    1.39 -        uuid_export(uuid, UUID_FMT_STR, out, NULL) != UUID_RC_OK)
    1.40 +        uuid_export(uuid, UUID_FMT_STR, &_out, &size) != UUID_RC_OK)
    1.41      {
    1.42          memset(out, 0, sizeof(uuid_string_t));
    1.43      }