]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libndb/ndbdiscard.c
games/nes: workaround for truncated chr
[plan9front.git] / sys / src / libndb / ndbdiscard.c
1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 #include <ndb.h>
5
6 /* remove a from t and free it */
7 Ndbtuple*
8 ndbdiscard(Ndbtuple *t, Ndbtuple *a)
9 {
10         Ndbtuple *nt;
11
12         /* unchain a */
13         for(nt = t; nt != nil; nt = nt->entry){
14                 if(nt->line == a)
15                         nt->line = a->line;
16                 if(nt->entry == a)
17                         nt->entry = a->entry;
18         }
19
20         /* a may be start of chain */
21         if(t == a)
22                 t = a->entry;
23
24         /* free a */
25         a->entry = nil;
26         ndbfree(a);
27
28         return t;
29 }