MCPcopy Create free account
hub / github.com/F-Stack/f-stack / graph_alloc_vertex

Function graph_alloc_vertex

freebsd/kern/kern_lockf.c:2406–2433  ·  view source on GitHub ↗

* Allocate a vertex from the free list. Return ENOMEM if there are * none. */

Source from the content-addressed store, hash-verified

2404 * none.
2405 */
2406static struct owner_vertex *
2407graph_alloc_vertex(struct owner_graph *g, struct lock_owner *lo)
2408{
2409 struct owner_vertex *v;
2410
2411 sx_assert(&lf_owner_graph_lock, SX_XLOCKED);
2412
2413 v = malloc(sizeof(struct owner_vertex), M_LOCKF, M_WAITOK);
2414 if (g->g_size == g->g_space) {
2415 g->g_vertices = realloc(g->g_vertices,
2416 2 * g->g_space * sizeof(struct owner_vertex *),
2417 M_LOCKF, M_WAITOK);
2418 free(g->g_indexbuf, M_LOCKF);
2419 g->g_indexbuf = malloc(2 * g->g_space * sizeof(int),
2420 M_LOCKF, M_WAITOK);
2421 g->g_space = 2 * g->g_space;
2422 }
2423 v->v_order = g->g_size;
2424 v->v_gen = g->g_gen;
2425 g->g_vertices[g->g_size] = v;
2426 g->g_size++;
2427
2428 LIST_INIT(&v->v_outedges);
2429 LIST_INIT(&v->v_inedges);
2430 v->v_owner = lo;
2431
2432 return (v);
2433}
2434
2435static void
2436graph_free_vertex(struct owner_graph *g, struct owner_vertex *v)

Callers 1

lf_alloc_vertexFunction · 0.85

Calls 3

mallocFunction · 0.85
reallocFunction · 0.70
freeFunction · 0.70

Tested by

no test coverage detected