~ubuntu-branches/ubuntu/lucid/dicelab/lucid

1 by Robert Lemmen
Import upstream version 0.5
1
#include <malloc.h>
2
#include <string.h>
3
4
#include "roll.h"
5
6
struct roll_value *new_roll_single(int num) {
7
	struct roll_value *ret = (struct roll_value*)malloc(
8
		sizeof(struct roll_value));
9
	ret->count = 1;
10
	ret->values = (int*)malloc(sizeof(int));
11
	ret->values[0] = num;
12
	return ret;
13
}
14
15
struct roll_value *new_roll_multi(int count) {
16
	struct roll_value *ret = (struct roll_value*)malloc(
17
		sizeof(struct roll_value));
18
	ret->count = count;
19
	ret->values = (int*)malloc(sizeof(int)*count);
20
	memset(ret->values, 0, sizeof(int)*count);
21
	return ret;
22
}
23
24
void free_roll(struct roll_value *v) {
25
	free(v->values);
26
	free(v);
27
}