Hi
While looking for a good string library for C language many developers suggested to use SDS. I am interested in using it in a project.
All sdshdr## structures looks like:
struct __attribute__ ((__packed__)) sdshdr16 {
uint16_t len; /* used */
uint16_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
I did not found where the member (char buf[]) is used. I commented in sds.h all the lines defining buf and build redis:
struct __attribute__ ((__packed__)) sdshdr16 {
uint16_t len; /* used */
uint16_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
/* char buf[]; */
};
No error were detected and all tests were passed.
So why buf is here?
Sincerely yours
Comment From: sundb
We did not directly use it to access the position of the string but manually calculated the offset, so you can't see it being used. You can just consider them as representations of memory layout.
Comment From: ferhat-ahak
We did not directly use it to access the position of the string but manually calculated the offset, so you can't see it being used. You can just consider them as representations of memory layout.
Thank you very much. It was a good occasion for me to learn about FAM.