ca->name, ca->fda->ea_code, ca->fda->type, ca->fda->f_type);
}
-static struct resclass ca_class = {
+static const struct resclass ca_class = {
.name = "Custom attribute",
.size = sizeof(struct custom_attribute),
.free = ca_free,
.dump = ca_dump,
- .lookup = NULL,
- .memsize = NULL,
};
struct custom_attribute *
e->n.next ? "scheduled" : "inactive");
}
-static struct resclass ev_class = {
- "Event",
- sizeof(event),
- (void (*)(resource *)) ev_postpone,
- ev_dump,
- NULL,
- NULL
+static const struct resclass ev_class = {
+ .name = "Event",
+ .size = sizeof(event),
+ .free = (void (*)(resource *)) ev_postpone,
+ .dump = ev_dump,
};
/**
static resource *lp_lookup(resource *, unsigned long);
static struct resmem lp_memsize(resource *r);
-static struct resclass lp_class = {
- "LinPool",
- sizeof(struct linpool),
- lp_free,
- lp_dump,
- lp_lookup,
- lp_memsize
+static const struct resclass lp_class = {
+ .name = "LinPool",
+ .size = sizeof(struct linpool),
+ .free = lp_free,
+ .dump = lp_dump,
+ .lookup = lp_lookup,
+ .memsize = lp_memsize,
};
/**
static resource *pool_lookup(resource *, unsigned long);
static struct resmem pool_memsize(resource *P);
-static struct resclass pool_class = {
- "Pool",
- sizeof(pool),
- pool_free,
- pool_dump,
- pool_lookup,
- pool_memsize
+static const struct resclass pool_class = {
+ .name = "Pool",
+ .size = sizeof(pool),
+ .free = pool_free,
+ .dump = pool_dump,
+ .lookup = pool_lookup,
+ .memsize = pool_memsize,
};
pool root_pool;
* from the @size field of the &resclass.
*/
void *
-ralloc(pool *p, struct resclass *c)
+ralloc(pool *p, const struct resclass *c)
{
resource *r = xmalloc(c->size);
bzero(r, c->size);
};
}
-static struct resclass mb_class = {
- "Memory",
- 0,
- mbl_free,
- mbl_debug,
- mbl_lookup,
- mbl_memsize
+static const struct resclass mb_class = {
+ .name = "Memory",
+ .size = 0,
+ .free = mbl_free,
+ .dump = mbl_debug,
+ .lookup = mbl_lookup,
+ .memsize = mbl_memsize,
};
/**
typedef struct resource {
node n; /* Inside resource pool */
- struct resclass *class; /* Resource class */
+ const struct resclass *class; /* Resource class */
} resource;
/* Resource class */
void rlookup(unsigned long); /* Look up address (only for debugging) */
void rmove(void *, pool *); /* Move to a different pool */
-void *ralloc(pool *, struct resclass *);
+void *ralloc(pool *, const struct resclass *);
extern pool root_pool;
list objs;
};
-static struct resclass sl_class = {
- "FakeSlab",
- sizeof(struct slab),
- slab_free,
- slab_dump,
- NULL,
- slab_memsize
+static const struct resclass sl_class = {
+ .name = "FakeSlab",
+ .size = sizeof(struct slab),
+ .free = slab_free,
+ .dump = slab_dump,
+ .memsize = slab_memsize,
};
struct sl_obj {
struct sl_head_list empty_heads, partial_heads, full_heads;
};
-static struct resclass sl_class = {
- "Slab",
- sizeof(struct slab),
- slab_free,
- slab_dump,
- slab_lookup,
- slab_memsize
+static const struct resclass sl_class = {
+ .name = "Slab",
+ .size = sizeof(struct slab),
+ .free = slab_free,
+ .dump = slab_dump,
+ .lookup = slab_lookup,
+ .memsize = slab_memsize,
};
#define SL_GET_HEAD(x) ((struct sl_head *) (((uintptr_t) (x)) & ~(page_size-1)))
}
-static struct resclass tm_class = {
- "Timer",
- sizeof(timer),
- tm_free,
- tm_dump,
- NULL,
- NULL
+static const struct resclass tm_class = {
+ .name = "Timer",
+ .size = sizeof(timer),
+ .free = tm_free,
+ .dump = tm_dump,
};
timer *
RDUMP(" [wanted]\n");
}
-static struct resclass olock_class = {
- "ObjLock",
- sizeof(struct object_lock),
- olock_free,
- olock_dump,
- NULL,
- NULL,
+static const struct resclass olock_class = {
+ .name = "ObjLock",
+ .size = sizeof(struct object_lock),
+ .free = olock_free,
+ .dump = olock_dump,
};
/**
r->name, net_label[r->addr_type], r->rt_count, r->use_count);
}
-static struct resclass rt_class = {
+static const struct resclass rt_class = {
.name = "Routing table",
.size = sizeof(struct rtable),
.free = rt_free,
.dump = rt_res_dump,
- .lookup = NULL,
- .memsize = NULL,
};
rtable *
HASH_WALK_END;
}
-static struct resclass bfd_request_class;
+static const struct resclass bfd_request_class;
struct bfd_request *
bfd_request_session(pool *p, ip_addr addr, ip_addr local,
RDUMP("(code %p, data %p)\n", req->hook, req->data);
}
-static struct resclass bfd_request_class = {
- "BFD request",
- sizeof(struct bfd_request),
- bfd_request_free,
- bfd_request_dump,
- NULL,
- NULL,
+static const struct resclass bfd_request_class = {
+ .name = "BFD request",
+ .size = sizeof(struct bfd_request),
+ .free = bfd_request_free,
+ .dump = bfd_request_dump,
};
};
}
-static struct resclass bmp_tx_resource_class = {
+static const struct resclass bmp_tx_resource_class = {
.name = "BMP TX buffers",
.size = sizeof(struct bmp_tx_resource),
.free = bmp_tx_resource_free,
RDUMP("(FILE *%p)\n", a->f);
}
-static struct resclass rf_class = {
- "FILE",
- sizeof(struct rfile),
- rf_free,
- rf_dump,
- NULL,
- NULL
+static const struct resclass rf_class = {
+ .name = "FILE",
+ .size = sizeof(struct rfile),
+ .free = rf_free,
+ .dump = rf_dump,
};
struct rfile *
s->iface ? s->iface->name : "none");
}
-static struct resclass sk_class = {
- "Socket",
- sizeof(sock),
- sk_free,
- sk_dump,
- NULL,
- NULL
+static const struct resclass sk_class = {
+ .name = "Socket",
+ .size = sizeof(sock),
+ .free = sk_free,
+ .dump = sk_dump,
};
/**