summaryrefslogtreecommitdiff
path: root/src/core/processors.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-04-19 18:36:28 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-04-19 18:36:28 (GMT)
commit3dada5fbc27777217625603905727364a0cc996d (patch)
tree0ff4b94aca92e64a9e01594b4421f86465560395 /src/core/processors.c
parentfad679ef8cd654646c9234ff8fd39507adad9b8e (diff)
Changed the way the key for an architecture is provided.
Diffstat (limited to 'src/core/processors.c')
-rw-r--r--src/core/processors.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/core/processors.c b/src/core/processors.c
index 224e9f7..7234365 100644
--- a/src/core/processors.c
+++ b/src/core/processors.c
@@ -98,33 +98,41 @@ bool register_processor_type(GType type)
{
bool result; /* Bilan à retourner */
GArchProcessor *proc; /* Instance pour consultation */
- const char *key; /* Désignation associée */
+ char *key; /* Désignation associée */
proc_t *new; /* Nouvel élément à définir */
+ result = false;
+
proc = g_object_new(type, NULL);
key = g_arch_processor_get_key(proc);
+ if (key == NULL) goto done;
+
+ result = (key != NULL);
+
G_LOCK(_pdef_access);
new = find_processor_by_key(key);
- result = (new == NULL);
-
- if (result)
+ if (new == NULL)
{
_processors_definitions = realloc(_processors_definitions,
++_processors_definitions_count * sizeof(proc_t));
new = &_processors_definitions[_processors_definitions_count - 1];
- new->key = strdup(key);
+ new->key = key;
new->type = type;
+ result = true;
+
}
G_UNLOCK(_pdef_access);
+ done:
+
g_object_unref(G_OBJECT(proc));
return result;