ndbdiscard.c 474 B

123456789101112131415161718192021222324252627282930
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include <ndb.h>
  5. /* remove a from t and free it */
  6. Ndbtuple*
  7. ndbdiscard(Ndbtuple *t, Ndbtuple *a)
  8. {
  9. Ndbtuple *nt;
  10. /* unchain a */
  11. for(nt = t; nt != nil; nt = nt->entry){
  12. if(nt->line == a)
  13. nt->line = a->line;
  14. if(nt->entry == a)
  15. nt->entry = a->entry;
  16. }
  17. /* a may be start of chain */
  18. if(t == a)
  19. t = a->entry;
  20. /* free a */
  21. a->entry = nil;
  22. ndbfree(a);
  23. ndbsetmalloctag(t, getcallerpc(&t));
  24. return t;
  25. }