* Allocate a vertex from the free list. Return ENOMEM if there are * none. */
| 2404 | * none. |
| 2405 | */ |
| 2406 | static struct owner_vertex * |
| 2407 | graph_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 | |
| 2435 | static void |
| 2436 | graph_free_vertex(struct owner_graph *g, struct owner_vertex *v) |
no test coverage detected