Function panda_sys::object_new_with_props[][src]

pub unsafe extern "C" fn object_new_with_props(
    typename: *const c_char,
    parent: *mut Object,
    id: *const c_char,
    errp: *mut *mut Error,
     ...
) -> *mut Object
Expand description

object_new_with_props: @typename: The name of the type of the object to instantiate. @parent: the parent object @id: The unique ID of the object @errp: pointer to error object @…: list of property names and values

This function will initialize a new object using heap allocated memory. The returned object has a reference count of 1, and will be freed when the last reference is dropped.

The @id parameter will be used when registering the object as a child of @parent in the composition tree.

The variadic parameters are a list of pairs of (propname, propvalue) strings. The propname of %NULL indicates the end of the property list. If the object implements the user creatable interface, the object will be marked complete once all the properties have been processed.

Creating an object with properties Error *err = NULL; Object *obj;

obj = object_new_with_props(TYPE_MEMORY_BACKEND_FILE, object_get_objects_root(), “hostmem0”, &err, “share”, “yes”, “mem-path”, “/dev/shm/somefile”, “prealloc”, “yes”, “size”, “1048576”, NULL);

if (!obj) { g_printerr(“Cannot create memory backend: %s\n”, error_get_pretty(err)); }

The returned object will have one stable reference maintained for as long as it is present in the object hierarchy.

Returns: The newly allocated, instantiated & initialized object.