source: mainline/uspace/srv/sysman/unit.c@ f42ee6f

Last change on this file since f42ee6f was f42ee6f, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago

Add basic structures for sysman
Conflicts:

boot/Makefile.common

  • Property mode set to 100644
File size: 750 bytes
Line 
1#include <assert.h>
2#include <mem.h>
3#include <stdlib.h>
4
5#include "unit.h"
6
7static void unit_init(unit_t *unit, unit_type_t type)
8{
9 assert(unit);
10
11 memset(unit, 0, sizeof(unit));
12
13 link_initialize(&unit->units);
14 list_initialize(&unit->dependants);
15 list_initialize(&unit->dependencies);
16
17 unit->type = type;
18 unit->state = STATE_EMBRYO;
19}
20
21unit_t *unit_create(unit_type_t type)
22{
23 unit_t *unit = malloc(sizeof(unit_t));
24 if (unit != NULL) {
25 unit_init(unit, type);
26 }
27 return unit;
28}
29
30/** Release resources used by unit structure */
31void unit_destroy(unit_t **unit)
32{
33 if (*unit == NULL)
34 return;
35 /* TODO:
36 * edges,
37 * specific unit data,
38 * check it's not an active unit,
39 * other resources to come
40 */
41 free(*unit);
42 *unit = NULL;
43}
Note: See TracBrowser for help on using the repository browser.