record-manager-solved/include/list.h
trevon 8c08fb626f
Some checks are pending
grade / grade (push) Waiting to run
push (solved)
2026-08-26 01:12:23 +00:00

22 lines
976 B
C

#ifndef LIST_H
#define LIST_H
#include "record.h"
/*
* Singly linked list of records (Milestone 3). Opaque handle: callers can
* never touch node fields — they go through the functions below.
*/
typedef struct list list_t;
list_t *list_new(void); /* empty list; NULL on OOM */
void list_free(list_t *l); /* frees every node + record */
int list_append(list_t *l, record_t *r); /* add to end; 0 ok, -1 OOM */
record_t *list_find(list_t *l, const char *name);/* exact name match; NULL if none */
int list_remove(list_t *l, const char *name); /* remove + free match; 0 ok,
STATUS_ERR_NOTFOUND if absent */
size_t list_len(const list_t *l); /* number of records */
record_t *list_get(const list_t *l, size_t i); /* i-th record; NULL if OOB */
int list_sort(list_t *l); /* alphabetical by name (M5) */
#endif /* LIST_H */