Greenbone Vulnerability Management Libraries  11.0.1
uuidutils.c File Reference

UUID creation. More...

#include "uuidutils.h"
#include <glib.h>
#include <stdlib.h>
#include <uuid/uuid.h>
Include dependency graph for uuidutils.c:

Go to the source code of this file.

Functions

char * gvm_uuid_make (void)
 Make a new universal identifier. More...
 

Detailed Description

UUID creation.

Definition in file uuidutils.c.

Function Documentation

◆ gvm_uuid_make()

char* gvm_uuid_make ( void  )

Make a new universal identifier.

Returns
A newly allocated string holding the identifier, which the caller must free, or NULL on failure.

Definition at line 38 of file uuidutils.c.

39 {
40  char *id;
41  uuid_t uuid;
42 
43  /* Generate an UUID. */
44  uuid_generate (uuid);
45  if (uuid_is_null (uuid) == 1)
46  {
47  g_warning ("%s: failed to generate UUID", __FUNCTION__);
48  return NULL;
49  }
50 
51  /* Allocate mem for string to hold UUID. */
52  id = g_malloc0 (sizeof (char) * 37);
53  if (id == NULL)
54  {
55  g_warning ("%s: Cannot export UUID to text: out of memory", __FUNCTION__);
56  return NULL;
57  }
58 
59  /* Export the UUID to text. */
60  uuid_unparse (uuid, id);
61 
62  return id;
63 }