Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[dyn-config] Add modedata_copy() function
Enabler for having privately owned mode data in the worker thread.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Apr 9, 2019
1 parent 1c90322 commit ac5a4dc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/usb_moded-dyn-config.c
Expand Up @@ -43,6 +43,7 @@

static void modedata_free_cb(gpointer self);
void modedata_free (modedata_t *self);
modedata_t *modedata_copy (const modedata_t *that);
static gint modedata_sort_cb(gconstpointer a, gconstpointer b);
static modedata_t *modedata_load (const gchar *filename);

Expand Down Expand Up @@ -100,6 +101,52 @@ modedata_free(modedata_t *self)
}
}

/** Clone modedata_t object
*
* @param that Object pointer, or NULL
*
* @return Object pointer, or NULL
*/
modedata_t *
modedata_copy(const modedata_t *that)
{
modedata_t *self = 0;

if( !that )
goto EXIT;

if( !(self = calloc(1, sizeof *self)) )
goto EXIT;

self->mode_name = g_strdup(that->mode_name);
self->mode_module = g_strdup(that->mode_module);
self->appsync = that->appsync;
self->network = that->network;
self->mass_storage = that->mass_storage;
self->network_interface = g_strdup(that->network_interface);
self->sysfs_path = g_strdup(that->sysfs_path);
self->sysfs_value = g_strdup(that->sysfs_value);
self->sysfs_reset_value = g_strdup(that->sysfs_reset_value);
self->android_extra_sysfs_path = g_strdup(that->android_extra_sysfs_path);
self->android_extra_sysfs_value = g_strdup(that->android_extra_sysfs_value);
self->android_extra_sysfs_path2 = g_strdup(that->android_extra_sysfs_path2);
self->android_extra_sysfs_value2 = g_strdup(that->android_extra_sysfs_value2);
self->android_extra_sysfs_path3 = g_strdup(that->android_extra_sysfs_path3);
self->android_extra_sysfs_value3 = g_strdup(that->android_extra_sysfs_value3);
self->android_extra_sysfs_path4 = g_strdup(that->android_extra_sysfs_path4);
self->android_extra_sysfs_value4 = g_strdup(that->android_extra_sysfs_value4);
self->idProduct = g_strdup(that->idProduct);
self->idVendorOverride = g_strdup(that->idVendorOverride);
self->nat = that->nat;
self->dhcp_server = that->dhcp_server;
#ifdef CONNMAN
self->connman_tethering = g_strdup(that->connman_tethering);
#endif

EXIT:
return self;
}

/** Callback for sorting mode list alphabetically
*
* For use with g_list_sort()
Expand Down
1 change: 1 addition & 0 deletions src/usb_moded-dyn-config.h
Expand Up @@ -131,6 +131,7 @@ typedef struct modedata_t
* ------------------------------------------------------------------------- */

void modedata_free(modedata_t *self);
modedata_t *modedata_copy(const modedata_t *that);

/* ------------------------------------------------------------------------- *
* MODELIST
Expand Down

0 comments on commit ac5a4dc

Please sign in to comment.