adding a few asserts for ex19
This commit is contained in:
parent
1695ec3796
commit
891013a781
2
object.c
2
object.c
@ -46,6 +46,7 @@ int Object_attack(void *self, int damage)
|
||||
|
||||
void *Object_new(size_t size, Object proto, char *description)
|
||||
{
|
||||
assert(description != NULL);
|
||||
// setup the default functions in case they aren't set
|
||||
if(!proto.init) proto.init = Object_init;
|
||||
if(!proto.describe) proto.describe = Object_describe;
|
||||
@ -56,6 +57,7 @@ void *Object_new(size_t size, Object proto, char *description)
|
||||
// this seems weird, but we can make a struct of one size,
|
||||
// then point a different pointer at it to "cast" it
|
||||
Object *el = calloc(size, 1);
|
||||
assert(el != NULL);
|
||||
*el = proto;
|
||||
|
||||
// copy the description over
|
||||
|
Loading…
Reference in New Issue
Block a user