Just some cosmetics.

This commit is contained in:
Johannes Findeisen 2026-10-02 00:33:43 +02:00
commit 6ca258f882
6 changed files with 21 additions and 21 deletions

View file

@ -38,8 +38,8 @@
*/
static char *dupstr(const char *text)
{
size_t len;
char *copy;
size_t len;
char *copy;
if (!text)
return NULL;

View file

@ -38,10 +38,10 @@ struct AnimalVTable {
* struct as their first member, which makes the upcast free.
*/
struct Animal {
ooc_object object;
ooc_object object;
const AnimalVTable *vtable;
char *name;
int age;
char *name;
int age;
/*
* Two fields that belong to the class alone, told apart by their leading
@ -52,8 +52,8 @@ struct Animal {
* nothing outside Animal can read or write it by name at all. Both are set
* from the struct definition below, where the members are in view.
*/
int _id;
int __legs;
int _id;
int __legs;
};
/*

View file

@ -43,8 +43,8 @@
*/
static char *dupstr(const char *text)
{
size_t len;
char *copy;
size_t len;
char *copy;
if (!text)
return NULL;
@ -157,10 +157,10 @@ static const ooc_field Cat_fields[] = {
* Dog stay distinguishable while both are passed around as Animal.
*/
const ooc_class Cat_class = {
.size = sizeof(Cat),
.size = sizeof(Cat),
.destroy = destroy,
.super = &Animal_class,
.fields = Cat_fields,
.super = &Animal_class,
.fields = Cat_fields,
};
/*
@ -203,8 +203,8 @@ Cat *cat_new(const char *name, int age, const char *colour)
}
cat->animal.vtable = &vt;
cat->colour = dupstr(colour);
cat->_lives = 9;
cat->colour = dupstr(colour);
cat->_lives = 9;
if (!cat->colour) {
ooc_release(cat);

View file

@ -32,7 +32,7 @@ typedef struct Cat Cat;
*/
struct Cat {
Animal animal;
char *colour;
char *colour;
/*
* Private to Cat, and readable by name: one leading underscore stops
@ -40,7 +40,7 @@ struct Cat {
* the same way, so the rule is the one in the library rather than something
* the subclass has to repeat.
*/
int _lives;
int _lives;
};
/*

View file

@ -41,8 +41,8 @@
*/
static char *dupstr(const char *text)
{
size_t len;
char *copy;
size_t len;
char *copy;
if (!text)
return NULL;
@ -128,7 +128,7 @@ static const AnimalVTable vt = {
*/
static const ooc_field Dog_fields[] = {
{ "breed", offsetof(Dog, breed), sizeof(((Dog *)0)->breed), 1 },
{ NULL, 0, 0, 0 },
{ NULL, 0, 0, 0 },
};
/*
@ -181,7 +181,7 @@ Dog *dog_new(const char *name, int age, const char *breed)
}
dog->animal.vtable = &vt;
dog->breed = dupstr(breed);
dog->breed = dupstr(breed);
if (!dog->breed) {
ooc_release(dog);

View file

@ -31,7 +31,7 @@ typedef struct Dog Dog;
*/
struct Dog {
Animal animal;
char *breed;
char *breed;
};
/*