Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

61 lignes
1.9 KiB

  1. /*
  2. * Lua RTOS, list data structure
  3. *
  4. * Copyright (C) 2015 - 2017
  5. * IBEROXARXA SERVICIOS INTEGRALES, S.L. & CSS IBÉRICA, S.L.
  6. *
  7. * Author: Jaume Olivé (jolive@iberoxarxa.com / jolive@whitecatboard.org)
  8. *
  9. * All rights reserved.
  10. *
  11. * Permission to use, copy, modify, and distribute this software
  12. * and its documentation for any purpose and without fee is hereby
  13. * granted, provided that the above copyright notice appear in all
  14. * copies and that both that the copyright notice and this
  15. * permission notice and warranty disclaimer appear in supporting
  16. * documentation, and that the name of the author not be used in
  17. * advertising or publicity pertaining to distribution of the
  18. * software without specific, written prior permission.
  19. *
  20. * The author disclaim all warranties with regard to this
  21. * software, including all implied warranties of merchantability
  22. * and fitness. In no event shall the author be liable for any
  23. * special, indirect or consequential damages or any damages
  24. * whatsoever resulting from loss of use, data or profits, whether
  25. * in an action of contract, negligence or other tortious action,
  26. * arising out of or in connection with the use or performance of
  27. * this software.
  28. */
  29. #ifndef _LIST_H
  30. #define _LIST_H
  31. #include <stdint.h>
  32. #include "mutex.h"
  33. struct list {
  34. struct mtx mutex;
  35. struct list_index *index;
  36. struct list_index *free;
  37. uint8_t indexes;
  38. uint8_t first_index;
  39. };
  40. struct list_index {
  41. void *item;
  42. uint8_t index;
  43. uint8_t deleted;
  44. struct list_index *next;
  45. };
  46. void list_init(struct list *list, int first_index);
  47. int list_add(struct list *list, void *item, int *item_index);
  48. int list_get(struct list *list, int index, void **item);
  49. int list_remove(struct list *list, int index, int destroy);
  50. int list_first(struct list *list);
  51. int list_next(struct list *list, int index);
  52. void list_destroy(struct list *list, int items);
  53. #endif /* LIST_H */