mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-23 10:53:40 +08:00
cdb6c2d66e
Required for size_t, reported by clang-tidy.
Fixes: 38943b20
("shared: use size_t for strbuf")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/172
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
32 lines
708 B
C
32 lines
708 B
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
/*
|
|
* Buffer abstract data type
|
|
*/
|
|
struct strbuf {
|
|
char *bytes;
|
|
size_t size;
|
|
size_t used;
|
|
};
|
|
|
|
void strbuf_init(struct strbuf *buf);
|
|
void strbuf_release(struct strbuf *buf);
|
|
void strbuf_clear(struct strbuf *buf);
|
|
|
|
/* Destroy buffer and return a copy as a C string */
|
|
char *strbuf_steal(struct strbuf *buf);
|
|
|
|
/*
|
|
* Return a C string owned by the buffer invalidated if the buffer is
|
|
* changed).
|
|
*/
|
|
const char *strbuf_str(struct strbuf *buf);
|
|
|
|
bool strbuf_pushchar(struct strbuf *buf, char ch);
|
|
size_t strbuf_pushchars(struct strbuf *buf, const char *str);
|
|
void strbuf_popchar(struct strbuf *buf);
|
|
void strbuf_popchars(struct strbuf *buf, size_t n);
|