Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* this header file comes from libowfat, http://www.fefe.de/libowfat/ */
  2. #ifndef ARRAY_H
  3. #define ARRAY_H
  4. #include <stddef.h>
  5. #include "uint64.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef struct {
  10. char* p;
  11. int64 allocated; /* in bytes */
  12. uint64 initialized; /* in bytes */
  13. /* p and allocated nonzero: array is allocated */
  14. /* p and allocated zero: array is unallocated */
  15. /* p zero and allocated < 0: array is failed */
  16. size_t headroom; /* the actual pointer for free() and realloc() is p-headroom */
  17. } array;
  18. void* array_allocate(array* x,uint64 membersize,int64 pos);
  19. void* array_get(const array* const x,uint64 membersize,int64 pos);
  20. void* array_start(const array* const x);
  21. int64 array_length(const array* const x,uint64 membersize);
  22. int64 array_bytes(const array* const x);
  23. void array_truncate(array* x,uint64 membersize,int64 len);
  24. void array_trunc(array* x);
  25. void array_reset(array* x);
  26. void array_fail(array* x);
  27. int array_equal(const array* const x,const array* const y);
  28. void array_cat(array* to,const array* const from);
  29. void array_catb(array* to,const char* from,uint64 len);
  30. void array_cats(array* to,const char* from);
  31. void array_cats0(array* to,const char* from);
  32. void array_cat0(array* to);
  33. void array_cate(array* to,const array* const from,int64 pos,int64 stop);
  34. void array_shift(array* x,uint64 membersize,uint64 members);
  35. void array_chop(array* x,uint64 membersize,uint64 members);
  36. #define array_failed(x) (array_bytes(x)==-1)
  37. #define array_unallocated(x) (array_bytes(x)==0)
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif