So, I'm trying to write a buffering library for the 64th time, and I'm starting to understand pretty advanced things. I thought that I would ask for some professional materials about this.
In my first header file, I have the following:
typedef struct StdBuffer { void* address; } StdBuffer;
extern void StdBufferClear(StdBuffer);
In another header file that #includes
has the first header file, I:
typedef struct CharBuffer { char* address; } CharBuffer;
void (*CharBufferClear)(CharBuffer) = (void*) StdBufferClear;
Will this function declare a void pointer to interfere with the call? They have a value comparison. I had never seen a function pointer declared by void before, but its only way to get it to compile.
Stackwise, this should not make any difference from what I learned in assembler coding.
irrelevant OMG! I just said Stackwise on StackOverflow!
.. , . , . , "" . , , "" . API, :
typedef struct StdBuffer {
size_t width;
size_t limit;
void * address;
size_t index;
size_t allocated;
StdBufferFlags flags;
} StdBuffer;
, memcpy, memmove .. , , , - , .
, :
typedef struct CharBuffer {
size_t width;
size_t limit;
char * address;
size_t index;
size_t allocated;
CharBufferFlags flags;
} CharBuffer;
, . , C - , address
address
, a byte
byte
, long
long
.
, C, , , ( )... , . , , (1, 2, 4, 8, sizeof (RandomStruct)), .
api, . , , , - . CharBuffer, .
StdBuffer
- , EVER, api, , .
, , . @ Google. , , , , api .
, Signed/Unsigned bit StdBufferFlags.
, .
#define BIT(I) (1UL << (I - 1))
typedef enum StdBufferFlags {
BUFFER_MALLOCD = BIT(1),
BUFFER_WRITEABLE = BIT(2),
BUFFER_READABLE = BIT(3),
BUFFER_MOVABLE = BIT(4)
}StdBufferFlags;