1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-21 07:34:08 +00:00
zap/facil.io/lib/facil/fiobj/fiobj4fio.h
2023-12-22 04:03:32 +01:00

21 lines
674 B
C

#ifndef H_FIOBJ4SOCK_H
#define H_FIOBJ4SOCK_H
/**
* Defines a helper for using fiobj with the sock library.
*/
#include <fio.h>
#include <fiobj.h>
static void fiobj4sock_dealloc(void *o) { fiobj_free((FIOBJ)o); }
/** send a FIOBJ object through a socket. */
static inline __attribute__((unused)) ssize_t fiobj_send_free(intptr_t uuid,
FIOBJ o) {
fio_str_info_s s = fiobj_obj2cstr(o);
return fio_write2(uuid, .data.buffer = (void *)(o),
.offset = (uintptr_t)(((intptr_t)s.data) - ((intptr_t)(o))),
.length = s.len, .after.dealloc = fiobj4sock_dealloc);
}
#endif