~ubuntu-branches/ubuntu/quantal/dicelab/quantal

« back to all changes in this revision

Viewing changes to roll.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Lemmen
  • Date: 2007-12-10 17:06:15 UTC
  • Revision ID: james.westby@ubuntu.com-20071210170615-q1av8grz0vjiv397
Tags: upstream-0.5
ImportĀ upstreamĀ versionĀ 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}