projects
/
vrlugburz
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
cleaned up the level view code
[vrlugburz]
/
tools
/
dunger
/
src
/
level.c
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include "level.h"
5
6
struct level *create_level(int xsz, int ysz)
7
{
8
struct level *lvl;
9
10
if(!(lvl = malloc(sizeof *lvl))) {
11
return 0;
12
}
13
if(!(lvl->cells = calloc(xsz * ysz, sizeof *lvl->cells))) {
14
free(lvl);
15
return 0;
16
}
17
lvl->width = xsz;
18
lvl->height = ysz;
19
return lvl;
20
}
21
22
void free_level(struct level *lvl)
23
{
24
if(!lvl) return;
25
free(lvl->cells);
26
free(lvl);
27
}