joylink_list.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __JD_LIST_H_
  2. #define __JD_LIST_H_
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "joylink.h"
  7. #include "yc_list.h"
  8. typedef int LIST_BOOL_t;
  9. #define LIST_BOOL_FALSE (0)
  10. #define LIST_BOOL_TRUE (1)
  11. #define mem_get(type, n) calloc(sizeof(type),n)
  12. #define mem_put(ptr) \
  13. do{ \
  14. free(ptr); \
  15. (ptr) = NULL; \
  16. }while(0)
  17. typedef enum __list_ret{
  18. E_LIST_RET_OK = 0,
  19. E_LIST_ERROR = -1,
  20. E_LIST_ERROR_PARAM_INVAILD = -2
  21. }E_LIST_RET;
  22. typedef struct _id_node
  23. {
  24. LHead_t list;
  25. int32_t id;
  26. int32_t len;
  27. void *data;
  28. }IDNode_t;
  29. //===========================
  30. /**
  31. * brief:
  32. *
  33. * @Param: id
  34. * @Param: lhead
  35. *
  36. * @Returns:
  37. */
  38. int32_t is_joylink_idnode_exist(int32_t id, LHead_t *lhead);
  39. /**
  40. *1 create the IDNode
  41. *2 data must be the malloc point
  42. */
  43. int32_t joylink_idnode_add(int32_t id, void *data, int32_t data_len, LHead_t *lhead);
  44. /**
  45. *1 free node->data
  46. *2 free node
  47. */
  48. int32_t joylink_idnode_del(int32_t id, LHead_t *lhead);
  49. /**
  50. * brief:
  51. *
  52. * @Param: size
  53. * @Param: pids
  54. * @Param: lhead
  55. *
  56. * @Returns:
  57. */
  58. int joylink_ids_get(int32_t size, int32_t *pids, LHead_t *lhead);
  59. /**
  60. * brief:
  61. *
  62. * @Param: id
  63. * @Param: lhead
  64. *
  65. * @Returns:
  66. */
  67. IDNode_t * joylink_idnode_get_by_id(int32_t id, LHead_t *lhead);
  68. /**
  69. * brief:
  70. *
  71. * @Param: lhead
  72. *
  73. * @Returns:
  74. */
  75. int32_t joylink_idnode_list_clear(LHead_t *lhead);
  76. /**
  77. * brief:
  78. *
  79. * @Param: lhead
  80. */
  81. void joylink_idnode_list_debugp(LHead_t *lhead);
  82. #endif