mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Simplify UUID generation in several places.
Replace code using ast_uuid_generate() with simpler and faster code using ast_uuid_generate_str(). The new code avoids a malloc(), free(), and copy. ........ Merged revisions 424103 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 424105 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@424109 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -550,6 +550,7 @@ static void session_datastore_destroy(void *obj)
|
||||
struct ast_datastore *ast_sip_session_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
|
||||
{
|
||||
RAII_VAR(struct ast_datastore *, datastore, NULL, ao2_cleanup);
|
||||
char uuid_buf[AST_UUID_STR_LEN];
|
||||
const char *uid_ptr = uid;
|
||||
|
||||
if (!info) {
|
||||
@@ -564,13 +565,7 @@ struct ast_datastore *ast_sip_session_alloc_datastore(const struct ast_datastore
|
||||
datastore->info = info;
|
||||
if (ast_strlen_zero(uid)) {
|
||||
/* They didn't provide an ID so we'll provide one ourself */
|
||||
struct ast_uuid *uuid = ast_uuid_generate();
|
||||
char uuid_buf[AST_UUID_STR_LEN];
|
||||
if (!uuid) {
|
||||
return NULL;
|
||||
}
|
||||
uid_ptr = ast_uuid_to_str(uuid, uuid_buf, sizeof(uuid_buf));
|
||||
ast_free(uuid);
|
||||
uid_ptr = ast_uuid_generate_str(uuid_buf, sizeof(uuid_buf));
|
||||
}
|
||||
|
||||
datastore->uid = ast_strdup(uid_ptr);
|
||||
|
Reference in New Issue
Block a user