static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)

{

    sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));

    CPUCore *cc = CPU_CORE(OBJECT(dev));

    const char *typename = object_class_get_name(sc->cpu_class);

    size_t size = object_type_get_instance_size(typename);

    Error *local_err = NULL;

    Object *obj;

    int i;



    sc->threads = g_malloc0(size * cc->nr_threads);

    for (i = 0; i < cc->nr_threads; i++) {

        char id[32];

        void *obj = sc->threads + i * size;



        object_initialize(obj, size, typename);

        snprintf(id, sizeof(id), "thread[%d]", i);

        object_property_add_child(OBJECT(sc), id, obj, &local_err);

        if (local_err) {

            goto err;

        }


    }

    object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err);

    if (local_err) {

        goto err;

    } else {

        return;

    }



err:

    while (--i >= 0) {

        obj = sc->threads + i * size;

        object_unparent(obj);

    }

    g_free(sc->threads);

    error_propagate(errp, local_err);

}
static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)

{

    sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));

    CPUCore *cc = CPU_CORE(OBJECT(dev));

    const char *typename = object_class_get_name(sc->cpu_class);

    size_t size = object_type_get_instance_size(typename);

    Error *local_err = NULL;

    Object *obj;

    int i;



    sc->threads = g_malloc0(size * cc->nr_threads);

    for (i = 0; i < cc->nr_threads; i++) {

        char id[32];

        void *obj = sc->threads + i * size;



        object_initialize(obj, size, typename);

        snprintf(id, sizeof(id), "thread[%d]", i);

        object_property_add_child(OBJECT(sc), id, obj, &local_err);

        if (local_err) {

            goto err;

        }


    }

    object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err);

    if (local_err) {

        goto err;

    } else {

        return;

    }



err:

    while (--i >= 0) {

        obj = sc->threads + i * size;

        object_unparent(obj);

    }

    g_free(sc->threads);

    error_propagate(errp, local_err);

}
static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)

{

    sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(VAR_0));

    CPUCore *cc = CPU_CORE(OBJECT(VAR_0));

    const char *VAR_2 = object_class_get_name(sc->cpu_class);

    size_t size = object_type_get_instance_size(VAR_2);

    Error *local_err = NULL;

    Object *obj;

    int VAR_3;



    sc->threads = g_malloc0(size * cc->nr_threads);

    for (VAR_3 = 0; VAR_3 < cc->nr_threads; VAR_3++) {

        char id[32];

        void *obj = sc->threads + VAR_3 * size;



        object_initialize(obj, size, VAR_2);

        snprintf(id, sizeof(id), "thread[%d]", VAR_3);

        object_property_add_child(OBJECT(sc), id, obj, &local_err);

        if (local_err) {

            goto err;

        }


    }

    object_child_foreach(OBJECT(VAR_0), spapr_cpu_core_realize_child, &local_err);

    if (local_err) {

        goto err;

    } else {

        return;

    }



err:

    while (--VAR_3 >= 0) {

        obj = sc->threads + VAR_3 * size;

        object_unparent(obj);

    }

    g_free(sc->threads);

    error_propagate(VAR_1, local_err);

}
static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{ sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(VAR_0)); CPUCore *cc = CPU_CORE(OBJECT(VAR_0)); const char *VAR_2 = object_class_get_name(sc->cpu_class); size_t size = object_type_get_instance_size(VAR_2); Error *local_err = NULL; Object *obj; int VAR_3; sc->threads = g_malloc0(size * cc->nr_threads); for (VAR_3 = 0; VAR_3 < cc->nr_threads; VAR_3++) { char id[32]; void *obj = sc->threads + VAR_3 * size; object_initialize(obj, size, VAR_2); snprintf(id, sizeof(id), "thread[%d]", VAR_3); object_property_add_child(OBJECT(sc), id, obj, &local_err); if (local_err) { goto err; } } object_child_foreach(OBJECT(VAR_0), spapr_cpu_core_realize_child, &local_err); if (local_err) { goto err; } else { return; } err:
while (--VAR_3 >= 0) { obj = sc->threads + VAR_3 * size; object_unparent(obj); } g_free(sc->threads); error_propagate(VAR_1, local_err); }