mirror of
https://github.com/AuxXxilium/kmod.git
synced 2024-11-23 23:10:53 +07:00
b34819bc0e
It fixes linking problem tools/depmod.o: In function `output_symbols_bin': depmod.c:(.text.output_symbols_bin+0x135): undefined reference to `scratchbuf_str' for -O0 build, where gcc doesn't actually inline it. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
32 lines
620 B
C
32 lines
620 B
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <shared/macro.h>
|
|
|
|
/*
|
|
* Buffer abstract data type
|
|
*/
|
|
struct scratchbuf {
|
|
char *bytes;
|
|
size_t size;
|
|
bool need_free;
|
|
};
|
|
|
|
void scratchbuf_init(struct scratchbuf *buf, char *stackbuf, size_t size);
|
|
int scratchbuf_alloc(struct scratchbuf *buf, size_t sz);
|
|
void scratchbuf_release(struct scratchbuf *buf);
|
|
|
|
/* Return a C string */
|
|
static inline char *scratchbuf_str(struct scratchbuf *buf)
|
|
{
|
|
return buf->bytes;
|
|
}
|
|
|
|
#define SCRATCHBUF_INITIALIZER(buf_) { \
|
|
.bytes = buf_, \
|
|
.size = sizeof(buf_) + _array_size_chk(buf_), \
|
|
.need_free = false, \
|
|
}
|