-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnamespace.c
More file actions
46 lines (42 loc) · 1.01 KB
/
Copy pathnamespace.c
File metadata and controls
46 lines (42 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
#include "./do.h"
extern DoNamespace *InitDoNamespace(char *name)
{
if (name == NULL)
{
// errno todo
Log(FATAL, "name is NULL for InitDoNamespace");
return NULL;
}
DoNamespace *namespace = malloc(sizeof(DoNamespace));
if (namespace == NULL)
{
Log(FATAL, "couldn't allocate memory for namespace");
return NULL;
}
namespace->name = name;
namespace->tasks = DoDynArrayInit(DYN_ARR_TASK, DEFAULT_DO_DYN_ARR_SIZE);
if (namespace->tasks == NULL)
{
Log(FATAL, "couldn't allocate memory for namespace tasks");
return NULL;
}
namespace->vars = NULL;
return namespace;
}
extern void FreeDoNamespace(DoNamespace *namespace)
{
if (namespace != NULL)
{
if (namespace->name != NULL)
{
free(namespace->name);
}
if (namespace->tasks != NULL)
{
FreeDoDynArray(namespace->tasks);
}
free(namespace);
}
}