summaryrefslogtreecommitdiff
path: root/comp/lucas-standen-NEA/code/ads/dict/dict.c
blob: 551afcaf1f70b0c5866dcafd8d6d58262091caf5 (plain)
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
#include <stdlib.h>
#include <string.h>

typedef struct dict_t {
	int id;
	void *data;
}dict_t;

dict_t *dictalloc(){
	dict_t *output = malloc(sizeof(dict_t));
	return output;
}

int dictset(dict_t *dict, int id, void *data){
	dict->id = id;
	
	dict->data = malloc(sizeof(data));
	if (dict->data == NULL)
		return 1;
	memcpy(dict->data, data, sizeof(data));
	
	return 0;
}

void dictfree(dict_t *dict){
	free(dict->data);
	free(dict);
}