DEFINE_TRIVIAL_REF_FUNC(type, name); \
DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func);
+#define DECLARE_TRIVIAL_REF_FUNC(type, name) \
+ type* name##_ref(type *p)
+
+#define DECLARE_TRIVIAL_UNREF_FUNC(type, name) \
+ type* name##_unref(type *p)
+
+#define DECLARE_TRIVIAL_REF_UNREF_FUNC(type, name) \
+ DECLARE_TRIVIAL_REF_FUNC(type, name); \
+ DECLARE_TRIVIAL_UNREF_FUNC(type, name)
+
#define DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC(type, name, free_func) \
DEFINE_PRIVATE_TRIVIAL_REF_FUNC(type, name); \
DEFINE_PRIVATE_TRIVIAL_UNREF_FUNC(type, name, free_func);
LogContext* log_context_new_strv_consume(char **fields);
LogContext* log_context_new_iov_consume(struct iovec *input_iovec, size_t n_input_iovec);
-LogContext *log_context_ref(LogContext *c);
-LogContext *log_context_unref(LogContext *c);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(LogContext, log_context);
DEFINE_TRIVIAL_CLEANUP_FUNC(LogContext*, log_context_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_destroy);
-DynamicUser *dynamic_user_ref(DynamicUser *user);
+DECLARE_TRIVIAL_REF_FUNC(DynamicUser, dynamic_user);
int exec_shared_runtime_acquire(Manager *m, const ExecContext *c, const char *id, bool create, ExecSharedRuntime **ret);
ExecSharedRuntime *exec_shared_runtime_destroy(ExecSharedRuntime *r);
-ExecSharedRuntime *exec_shared_runtime_unref(ExecSharedRuntime *r);
+DECLARE_TRIVIAL_UNREF_FUNC(ExecSharedRuntime, exec_shared_runtime);
DEFINE_TRIVIAL_CLEANUP_FUNC(ExecSharedRuntime*, exec_shared_runtime_unref);
int exec_shared_runtime_serialize(const Manager *m, FILE *f, FDSet *fds);
} Operation;
Operation *operation_new(OperationType type, sd_bus_message *m);
-Operation *operation_ref(Operation *operation);
-Operation *operation_unref(Operation *operation);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Operation, operation);
DEFINE_TRIVIAL_CLEANUP_FUNC(Operation*, operation_unref);
} Writer;
int writer_new(RemoteServer *server, Writer **ret);
-Writer* writer_ref(Writer *w);
-Writer* writer_unref(Writer *w);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Writer, writer);
DEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref);
}
MMapCache* mmap_cache_new(void);
-MMapCache* mmap_cache_ref(MMapCache *m);
-MMapCache* mmap_cache_unref(MMapCache *m);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(MMapCache, mmap_cache);
DEFINE_TRIVIAL_CLEANUP_FUNC(MMapCache*, mmap_cache_unref);
int mmap_cache_fd_get(
void netdev_enter_failed(NetDev *netdev);
int netdev_enter_ready(NetDev *netdev);
-NetDev* netdev_unref(NetDev *netdev);
-NetDev* netdev_ref(NetDev *netdev);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(NetDev, netdev);
DEFINE_TRIVIAL_DESTRUCTOR(netdev_destroy_callback, NetDev, netdev_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
#include "networkd-forward.h"
-IPv6Token* ipv6_token_ref(IPv6Token *token);
-IPv6Token* ipv6_token_unref(IPv6Token *token);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(IPv6Token, ipv6_token);
int dhcp_pd_generate_addresses(Link *link, const struct in6_addr *prefix, Hashmap **ret);
int ndisc_generate_addresses(Link *link, const struct in6_addr *prefix, uint8_t prefixlen, Hashmap **ret);
bool address_can_update(const Address *existing, const Address *requesting);
-Address* address_ref(Address *address);
-Address* address_unref(Address *address);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Address, address);
int address_new(Address **ret);
int address_new_static(Network *network, const char *filename, unsigned section_line, Address **ret);
void link_ntp_settings_clear(Link *link);
void link_dns_settings_clear(Link *link);
-Link* link_unref(Link *link);
-Link* link_ref(Link *link);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Link, link);
DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
struct hw_addr_data ll_addr;
} Neighbor;
-Neighbor* neighbor_ref(Neighbor *neighbor);
-Neighbor* neighbor_unref(Neighbor *neighbor);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Neighbor, neighbor);
int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret);
int neighbor_remove(Neighbor *neighbor, Link *link);
char **ntp;
} Network;
-Network *network_ref(Network *network);
-Network *network_unref(Network *network);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Network, network);
DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
int network_load(Manager *manager, OrderedHashmap **ret);
bool waiting_reply;
} Request;
-Request *request_ref(Request *req);
-Request *request_unref(Request *req);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Request, request);
DEFINE_TRIVIAL_CLEANUP_FUNC(Request*, request_unref);
void request_detach(Request *req);
extern const struct hash_ops route_hash_ops;
extern const struct hash_ops route_hash_ops_unref;
-Route* route_ref(Route *route);
-Route* route_unref(Route *route);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Route, route);
DEFINE_SECTION_CLEANUP_FUNCTIONS(Route, route_unref);
void route_detach(Route *route);
int fr_act_type_from_string(const char *s) _pure_;
const char* fr_act_type_to_string(int t) _const_;
-RoutingPolicyRule* routing_policy_rule_ref(RoutingPolicyRule *rule);
-RoutingPolicyRule* routing_policy_rule_unref(RoutingPolicyRule *rule);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(RoutingPolicyRule, routing_policy_rule);
void network_drop_invalid_routing_policy_rules(Network *network);
DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(QDisc, qdisc);
-QDisc* qdisc_ref(QDisc *qdisc);
-QDisc* qdisc_unref(QDisc *qdisc);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(QDisc, qdisc);
int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, unsigned section_line, QDisc **ret);
void qdisc_mark_recursive(QDisc *qdisc);
DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(TClass, tclass);
-TClass* tclass_ref(TClass *tclass);
-TClass* tclass_unref(TClass *tclass);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(TClass, tclass);
int tclass_new_static(TClassKind kind, Network *network, const char *filename, unsigned section_line, TClass **ret);
void tclass_mark_recursive(TClass *tclass);
void dns_remove_service(DnsServiceBrowser *sb, DnssdDiscoveredService *service);
DnssdDiscoveredService *dns_service_free(DnssdDiscoveredService *service);
-DnsServiceBrowser *dns_service_browser_ref(DnsServiceBrowser *sb);
-DnsServiceBrowser *dns_service_browser_unref(DnsServiceBrowser *sb);
-
-DnssdDiscoveredService *dnssd_discovered_service_ref(DnssdDiscoveredService *service);
-DnssdDiscoveredService *dnssd_discovered_service_unref(DnssdDiscoveredService *service);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsServiceBrowser, dns_service_browser);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnssdDiscoveredService, dnssd_discovered_service);
void dns_browse_services_purge(Manager *m, int family);
void dns_browse_services_restart(Manager *m);
DNS_QUERY_CNAME,
};
-DnsQueryCandidate* dns_query_candidate_ref(DnsQueryCandidate*);
-DnsQueryCandidate* dns_query_candidate_unref(DnsQueryCandidate*);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsQueryCandidate, dns_query_candidate);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQueryCandidate*, dns_query_candidate_unref);
void dns_query_candidate_notify(DnsQueryCandidate *c);
DnsDelegate *delegate,
const char *name);
-DnsSearchDomain* dns_search_domain_ref(DnsSearchDomain *d);
-DnsSearchDomain* dns_search_domain_unref(DnsSearchDomain *d);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsSearchDomain, dns_search_domain);
void dns_search_domain_unlink(DnsSearchDomain *d);
void dns_search_domain_move_back_and_unmark(DnsSearchDomain *d);
const char *server_name,
ResolveConfigSource config_source);
-DnsServer* dns_server_ref(DnsServer *s);
-DnsServer* dns_server_unref(DnsServer *s);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsServer, dns_server);
void dns_server_unlink(DnsServer *s);
void dns_server_move_back_and_unmark(DnsServer *s);
#if ENABLE_DNS_OVER_TLS
int dns_stream_connect_tls(DnsStream *s, void *tls_session);
#endif
-DnsStream *dns_stream_unref(DnsStream *s);
-DnsStream *dns_stream_ref(DnsStream *s);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsStream, dns_stream);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsStream*, dns_stream_unref);
void *userdata;
} Image;
-Image* image_unref(Image *i);
-Image* image_ref(Image *i);
-
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Image, image);
DEFINE_TRIVIAL_CLEANUP_FUNC(Image*, image_unref);
int image_find(RuntimeScope scope, ImageClass class, const char *name, const char *root, Image **ret);
} DnsAnswer;
DnsAnswer *dns_answer_new(size_t n);
-DnsAnswer *dns_answer_ref(DnsAnswer *a);
-DnsAnswer *dns_answer_unref(DnsAnswer *a);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsAnswer, dns_answer);
#define DNS_ANSWER_REPLACE(a, b) \
do { \
} DnsQuestion;
DnsQuestion *dns_question_new(size_t n);
-DnsQuestion *dns_question_ref(DnsQuestion *q);
-DnsQuestion *dns_question_unref(DnsQuestion *q);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsQuestion, dns_question);
int dns_question_new_address(DnsQuestion **ret, int family, const char *name, bool convert_idna);
int dns_question_new_reverse(DnsQuestion **ret, int family, const union in_addr_union *a);
DnsResourceKey* dns_resource_key_new_redirect(const DnsResourceKey *key, const DnsResourceRecord *cname);
int dns_resource_key_new_append_suffix(DnsResourceKey **ret, DnsResourceKey *key, char *name);
DnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char *name);
-DnsResourceKey* dns_resource_key_ref(DnsResourceKey *key);
-DnsResourceKey* dns_resource_key_unref(DnsResourceKey *key);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsResourceKey, dns_resource_key);
#define DNS_RESOURCE_KEY_REPLACE(a, b) \
do { \
DnsResourceRecord* dns_resource_record_new(DnsResourceKey *key);
DnsResourceRecord* dns_resource_record_new_full(uint16_t class, uint16_t type, const char *name);
-DnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr);
-DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(DnsResourceRecord, dns_resource_record);
#define DNS_RR_REPLACE(a, b) \
do { \
} GroupRecord;
GroupRecord* group_record_new(void);
-GroupRecord* group_record_ref(GroupRecord *g);
-GroupRecord* group_record_unref(GroupRecord *g);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(GroupRecord, group_record);
DEFINE_TRIVIAL_CLEANUP_FUNC(GroupRecord*, group_record_unref);
int loop_device_open_from_fd(int fd, int open_flags, int lock_op, LoopDevice **ret);
int loop_device_open_from_path(const char *path, int open_flags, int lock_op, LoopDevice **ret);
-LoopDevice* loop_device_ref(LoopDevice *d);
-LoopDevice* loop_device_unref(LoopDevice *d);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(LoopDevice, loop_device);
DEFINE_TRIVIAL_CLEANUP_FUNC(LoopDevice*, loop_device_unref);
void loop_device_relinquish(LoopDevice *d);
int tpm2_context_new(const char *device, Tpm2Context **ret_context);
int tpm2_context_new_or_warn(const char *device, Tpm2Context **ret_context);
-Tpm2Context *tpm2_context_ref(Tpm2Context *context);
-Tpm2Context *tpm2_context_unref(Tpm2Context *context);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Tpm2Context, tpm2_context);
DEFINE_TRIVIAL_CLEANUP_FUNC(Tpm2Context*, tpm2_context_unref);
typedef struct Tpm2Handle {
} UserRecord;
UserRecord* user_record_new(void);
-UserRecord* user_record_ref(UserRecord *h);
-UserRecord* user_record_unref(UserRecord *h);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(UserRecord, user_record);
DEFINE_TRIVIAL_CLEANUP_FUNC(UserRecord*, user_record_unref);
} \
struct _sd_useless_struct_to_allow_trailing_semicolon_
+#define _SD_DECLARE_TRIVIAL_REF_FUNC(name) \
+ name* name##_ref(name *p)
+
+#define _SD_DECLARE_TRIVIAL_UNREF_FUNC(name) \
+ name* name##_unref(name *p)
+
+#define _SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(name) \
+ _SD_DECLARE_TRIVIAL_REF_FUNC(name); \
+ _SD_DECLARE_TRIVIAL_UNREF_FUNC(name)
+
/* The following macro should be used in all public enums, to force 64-bit wideness on them, so that we can
* freely extend them later on, without breaking compatibility. */
#define _SD_ENUM_FORCE_S64(id) \
int sd_bus_try_close(sd_bus *bus) _sd_deprecated_;
void sd_bus_close(sd_bus *bus);
-sd_bus* sd_bus_ref(sd_bus *bus);
-sd_bus* sd_bus_unref(sd_bus *bus);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_bus);
sd_bus* sd_bus_close_unref(sd_bus *bus);
sd_bus* sd_bus_flush_close_unref(sd_bus *bus);
/* Slot object */
-sd_bus_slot* sd_bus_slot_ref(sd_bus_slot *slot);
-sd_bus_slot* sd_bus_slot_unref(sd_bus_slot *slot);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_bus_slot);
sd_bus* sd_bus_slot_get_bus(sd_bus_slot *slot);
void* sd_bus_slot_get_userdata(sd_bus_slot *slot);
int sd_bus_message_new_method_errno(sd_bus_message *call, sd_bus_message **ret, int error, const sd_bus_error *e);
int sd_bus_message_new_method_errnof(sd_bus_message *call, sd_bus_message **ret, int error, const char *format, ...) _sd_printf_(4, 5);
-sd_bus_message* sd_bus_message_ref(sd_bus_message *m);
-sd_bus_message* sd_bus_message_unref(sd_bus_message *m);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_bus_message);
int sd_bus_message_seal(sd_bus_message *m, uint64_t cookie, uint64_t timeout_usec);
int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t creds_mask);
int sd_bus_creds_new_from_pidfd(sd_bus_creds **ret, int pidfd, uint64_t creds_mask);
-sd_bus_creds* sd_bus_creds_ref(sd_bus_creds *c);
-sd_bus_creds* sd_bus_creds_unref(sd_bus_creds *c);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_bus_creds);
uint64_t sd_bus_creds_get_mask(const sd_bus_creds *c);
uint64_t sd_bus_creds_get_augmented_mask(const sd_bus_creds *c);
/* Tracking peers */
int sd_bus_track_new(sd_bus *bus, sd_bus_track **ret, sd_bus_track_handler_t handler, void *userdata);
-sd_bus_track* sd_bus_track_ref(sd_bus_track *track);
-sd_bus_track* sd_bus_track_unref(sd_bus_track *track);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_bus_track);
sd_bus* sd_bus_track_get_bus(sd_bus_track *track);
void* sd_bus_track_get_userdata(sd_bus_track *track);
/* device */
-sd_device* sd_device_ref(sd_device *device);
-sd_device* sd_device_unref(sd_device *device);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_device);
int sd_device_new_from_syspath(sd_device **ret, const char *syspath);
int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum);
/* device enumerator */
int sd_device_enumerator_new(sd_device_enumerator **ret);
-sd_device_enumerator* sd_device_enumerator_ref(sd_device_enumerator *enumerator);
-sd_device_enumerator* sd_device_enumerator_unref(sd_device_enumerator *enumerator);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_device_enumerator);
sd_device* sd_device_enumerator_get_device_first(sd_device_enumerator *enumerator);
sd_device* sd_device_enumerator_get_device_next(sd_device_enumerator *enumerator);
/* device monitor */
int sd_device_monitor_new(sd_device_monitor **ret);
-sd_device_monitor* sd_device_monitor_ref(sd_device_monitor *m);
-sd_device_monitor* sd_device_monitor_unref(sd_device_monitor *m);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_device_monitor);
int sd_device_monitor_get_fd(sd_device_monitor *m);
int sd_device_monitor_get_events(sd_device_monitor *m);
int sd_dhcp_client_set_ipv6_connectivity(sd_dhcp_client *client, int have);
int sd_dhcp_client_interrupt_ipv6_only_mode(sd_dhcp_client *client);
-sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
-sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp_client);
/* NOTE: anonymize parameter is used to initialize PRL memory with different
* options when using RFC7844 Anonymity Profiles */
typedef struct sd_dhcp_route sd_dhcp_route;
typedef struct sd_dns_resolver sd_dns_resolver;
-sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease);
-sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp_lease);
__extension__ typedef enum _SD_ENUM_TYPE_S64(sd_dhcp_lease_server_type_t) {
SD_DHCP_LEASE_DNS,
typedef struct sd_dhcp_option sd_dhcp_option;
int sd_dhcp_option_new(uint8_t option, const void *data, size_t length, sd_dhcp_option **ret);
-sd_dhcp_option *sd_dhcp_option_ref(sd_dhcp_option *ra);
-sd_dhcp_option *sd_dhcp_option_unref(sd_dhcp_option *ra);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp_option);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_option, sd_dhcp_option_unref);
typedef struct sd_dhcp_server_lease sd_dhcp_server_lease;
-sd_dhcp_server_lease *sd_dhcp_server_lease_ref(sd_dhcp_server_lease *lease);
-sd_dhcp_server_lease *sd_dhcp_server_lease_unref(sd_dhcp_server_lease *lease);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp_server_lease);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_server_lease, sd_dhcp_server_lease_unref);
int sd_dhcp_server_set_ifname(sd_dhcp_server *server, const char *ifname);
int sd_dhcp_server_get_ifname(sd_dhcp_server *server, const char **ret);
-sd_dhcp_server *sd_dhcp_server_ref(sd_dhcp_server *server);
-sd_dhcp_server *sd_dhcp_server_unref(sd_dhcp_server *server);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp_server);
int sd_dhcp_server_attach_event(sd_dhcp_server *server, sd_event *event, int64_t priority);
int sd_dhcp_server_detach_event(sd_dhcp_server *server);
int sd_dhcp6_client_detach_event(sd_dhcp6_client *client);
sd_event *sd_dhcp6_client_get_event(sd_dhcp6_client *client);
int sd_dhcp6_client_attach_device(sd_dhcp6_client *client, sd_device *dev);
-sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client);
-sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp6_client);
int sd_dhcp6_client_new(sd_dhcp6_client **ret);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp6_client, sd_dhcp6_client_unref);
int sd_dhcp6_lease_get_captive_portal(sd_dhcp6_lease *lease, const char **ret);
int sd_dhcp6_lease_get_vendor_options(sd_dhcp6_lease *lease, sd_dhcp6_option ***ret);
-sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease);
-sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp6_lease);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp6_lease, sd_dhcp6_lease_unref);
typedef struct sd_dhcp6_option sd_dhcp6_option;
int sd_dhcp6_option_new(uint16_t option, const void *data, size_t length, uint32_t enterprise_identifier, sd_dhcp6_option **ret);
-sd_dhcp6_option *sd_dhcp6_option_ref(sd_dhcp6_option *ra);
-sd_dhcp6_option *sd_dhcp6_option_unref(sd_dhcp6_option *ra);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp6_option);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp6_option, sd_dhcp6_option_unref);
int sd_event_default(sd_event **ret);
int sd_event_new(sd_event **ret);
-sd_event* sd_event_ref(sd_event *e);
-sd_event* sd_event_unref(sd_event *e);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_event);
int sd_event_add_io(sd_event *e, sd_event_source **ret, int fd, uint32_t events, sd_event_io_handler_t callback, void *userdata);
int sd_event_add_time(sd_event *e, sd_event_source **ret, clockid_t clock, uint64_t usec, uint64_t accuracy, sd_event_time_handler_t callback, void *userdata);
int sd_event_set_exit_on_idle(sd_event *e, int b);
int sd_event_get_exit_on_idle(sd_event *e);
-sd_event_source* sd_event_source_ref(sd_event_source *s);
-sd_event_source* sd_event_source_unref(sd_event_source *s);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_event_source);
sd_event_source* sd_event_source_disable_unref(sd_event_source *s);
sd_event* sd_event_source_get_event(sd_event_source *s);
typedef struct sd_hwdb sd_hwdb;
-sd_hwdb *sd_hwdb_ref(sd_hwdb *hwdb);
-sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_hwdb);
int sd_hwdb_new(sd_hwdb **ret);
int sd_hwdb_new_from_path(const char *path, sd_hwdb **ret);
int sd_ipv4acd_is_bound(sd_ipv4acd *acd);
__extension__ int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts);
int sd_ipv4acd_stop(sd_ipv4acd *acd);
-sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *acd);
-sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *acd);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_ipv4acd);
int sd_ipv4acd_new(sd_ipv4acd **ret);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ipv4acd, sd_ipv4acd_unref);
int sd_ipv4ll_restart(sd_ipv4ll *ll);
int sd_ipv4ll_start(sd_ipv4ll *ll);
int sd_ipv4ll_stop(sd_ipv4ll *ll);
-sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll);
-sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_ipv4ll);
int sd_ipv4ll_new(sd_ipv4ll **ret);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ipv4ll, sd_ipv4ll_unref);
typedef void (*sd_lldp_rx_callback_t)(sd_lldp_rx *lldp_rx, sd_lldp_rx_event_t event, sd_lldp_neighbor *n, void *userdata);
int sd_lldp_rx_new(sd_lldp_rx **ret);
-sd_lldp_rx *sd_lldp_rx_ref(sd_lldp_rx *lldp_rx);
-sd_lldp_rx *sd_lldp_rx_unref(sd_lldp_rx *lldp_rx);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_lldp_rx);
int sd_lldp_rx_start(sd_lldp_rx *lldp_rx);
int sd_lldp_rx_stop(sd_lldp_rx *lldp_rx);
int sd_lldp_rx_get_neighbors(sd_lldp_rx *lldp_rx, sd_lldp_neighbor ***ret);
-sd_lldp_neighbor *sd_lldp_neighbor_ref(sd_lldp_neighbor *n);
-sd_lldp_neighbor *sd_lldp_neighbor_unref(sd_lldp_neighbor *n);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_lldp_neighbor);
/* Access to LLDP frame metadata */
int sd_lldp_neighbor_get_source_address(sd_lldp_neighbor *n, struct ether_addr* address);
} sd_lldp_multicast_mode_t;
int sd_lldp_tx_new(sd_lldp_tx **ret);
-sd_lldp_tx *sd_lldp_tx_ref(sd_lldp_tx *lldp_tx);
-sd_lldp_tx *sd_lldp_tx_unref(sd_lldp_tx *lldp_tx);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_lldp_tx);
int sd_lldp_tx_start(sd_lldp_tx *lldp_tx);
int sd_lldp_tx_stop(sd_lldp_tx *lldp_tx);
typedef struct sd_ndisc_neighbor sd_ndisc_neighbor;
-sd_ndisc_neighbor *sd_ndisc_neighbor_ref(sd_ndisc_neighbor *na);
-sd_ndisc_neighbor *sd_ndisc_neighbor_unref(sd_ndisc_neighbor *na);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_ndisc_neighbor);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc_neighbor, sd_ndisc_neighbor_unref);
int sd_ndisc_neighbor_get_sender_address(sd_ndisc_neighbor *na, struct in6_addr *ret);
typedef struct sd_ndisc_redirect sd_ndisc_redirect;
-sd_ndisc_redirect* sd_ndisc_redirect_ref(sd_ndisc_redirect *rd);
-sd_ndisc_redirect* sd_ndisc_redirect_unref(sd_ndisc_redirect *rd);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_ndisc_redirect);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc_redirect, sd_ndisc_redirect_unref);
int sd_ndisc_redirect_set_sender_address(sd_ndisc_redirect *rd, const struct in6_addr *addr);
typedef struct sd_ndisc_router_solicit sd_ndisc_router_solicit;
-sd_ndisc_router_solicit *sd_ndisc_router_solicit_ref(sd_ndisc_router_solicit *rs);
-sd_ndisc_router_solicit *sd_ndisc_router_solicit_unref(sd_ndisc_router_solicit *rs);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_ndisc_router_solicit);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc_router_solicit, sd_ndisc_router_solicit_unref);
int sd_ndisc_router_solicit_get_sender_address(sd_ndisc_router_solicit *rs, struct in6_addr *ret);
typedef struct sd_ndisc_router sd_ndisc_router;
typedef struct sd_dns_resolver sd_dns_resolver;
-sd_ndisc_router *sd_ndisc_router_ref(sd_ndisc_router *rt);
-sd_ndisc_router *sd_ndisc_router_unref(sd_ndisc_router *rt);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_ndisc_router);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc_router, sd_ndisc_router_unref);
int sd_ndisc_router_set_sender_address(sd_ndisc_router *rt, const struct in6_addr *addr);
typedef void (*sd_ndisc_callback_t)(sd_ndisc *nd, sd_ndisc_event_t event, void *message, void *userdata);
int sd_ndisc_new(sd_ndisc **ret);
-sd_ndisc *sd_ndisc_ref(sd_ndisc *nd);
-sd_ndisc *sd_ndisc_unref(sd_ndisc *nd);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_ndisc);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc, sd_ndisc_unref);
int sd_ndisc_start(sd_ndisc *nd);
int sd_netlink_open_fd(sd_netlink **ret, int fd);
int sd_netlink_increase_rxbuf(sd_netlink *nl, size_t size);
-sd_netlink* sd_netlink_ref(sd_netlink *nl);
-sd_netlink* sd_netlink_unref(sd_netlink *nl);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_netlink);
int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *ret_serial);
int sd_netlink_call_async(sd_netlink *nl, sd_netlink_slot **ret_slot, sd_netlink_message *message,
sd_netlink_message* sd_netlink_message_next(sd_netlink_message *m);
-sd_netlink_message* sd_netlink_message_ref(sd_netlink_message *m);
-sd_netlink_message* sd_netlink_message_unref(sd_netlink_message *m);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_netlink_message);
int sd_netlink_message_set_request_dump(sd_netlink_message *m, int dump);
int sd_netlink_message_is_error(sd_netlink_message *m);
void *userdata, const char *description);
/* slot */
-sd_netlink_slot *sd_netlink_slot_ref(sd_netlink_slot *slot);
-sd_netlink_slot *sd_netlink_slot_unref(sd_netlink_slot *slot);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_netlink_slot);
sd_netlink* sd_netlink_slot_get_netlink(sd_netlink_slot *slot);
void* sd_netlink_slot_get_userdata(sd_netlink_slot *slot);
typedef struct sd_radv sd_radv;
int sd_radv_new(sd_radv **ret);
-sd_radv *sd_radv_ref(sd_radv *ra);
-sd_radv *sd_radv_unref(sd_radv *ra);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_radv);
int sd_radv_attach_event(sd_radv *ra, sd_event *event, int64_t priority);
int sd_radv_detach_event(sd_radv *ra);
/* Free a sd-resolve session. This destroys all attached
* sd_resolve_query objects automatically. */
-sd_resolve* sd_resolve_unref(sd_resolve *resolve);
-sd_resolve* sd_resolve_ref(sd_resolve *resolve);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_resolve);
/* Return the UNIX file descriptor to poll() for events on. Use this
* function to integrate sd-resolve with your custom main loop. */
* if you want to query the hostname (resp. the service name). */
int sd_resolve_getnameinfo(sd_resolve *resolve, sd_resolve_query **ret, const struct sockaddr *sa, socklen_t salen, int flags, uint64_t get, sd_resolve_getnameinfo_handler_t callback, void *userdata);
-sd_resolve_query *sd_resolve_query_ref(sd_resolve_query *q);
-sd_resolve_query *sd_resolve_query_unref(sd_resolve_query *q);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_resolve_query);
/* Returns non-zero when the query operation specified by q has been completed. */
int sd_resolve_query_is_done(sd_resolve_query *q);
int sd_varlink_connect_fd(sd_varlink **ret, int fd);
int sd_varlink_connect_fd_pair(sd_varlink **ret, int input_fd, int output_fd, const struct ucred *override_ucred);
-sd_varlink* sd_varlink_ref(sd_varlink *link);
-sd_varlink* sd_varlink_unref(sd_varlink *v);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_varlink);
int sd_varlink_get_fd(sd_varlink *v);
int sd_varlink_get_input_fd(sd_varlink *v);
/* Create a varlink server */
int sd_varlink_server_new(sd_varlink_server **ret, sd_varlink_server_flags_t flags);
-sd_varlink_server* sd_varlink_server_ref(sd_varlink_server *s);
-sd_varlink_server* sd_varlink_server_unref(sd_varlink_server *s);
+_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC(sd_varlink_server);
int sd_varlink_server_set_info(
sd_varlink_server *s,
Feature *feature_new(void);
-Feature *feature_ref(Feature *f);
-Feature *feature_unref(Feature *f);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(Feature, feature);
DEFINE_TRIVIAL_CLEANUP_FUNC(Feature*, feature_unref);
extern const struct hash_ops feature_hash_ops;
text += f' {{ "{m[1]}", {m[1]} }},\n'
continue
+ # Functions declared by ref/unref macros
+ m = re.search(r'_SD_DECLARE_TRIVIAL_REF_UNREF_FUNC\((\w+)\)', line)
+ if m:
+ text += f' {{ "{m[1]}_ref", {m[1]}_ref }},\n'
+ text += f' {{ "{m[1]}_unref", {m[1]}_unref }},\n'
+ continue
+
+ m = re.search(r'_SD_DECLARE_TRIVIAL_REF_FUNC\((\w+)\)', line)
+ if m:
+ text += f' {{ "{m[1]}_ref", {m[1]}_ref }},\n'
+ continue
+
+ m = re.search(r'_SD_DECLARE_TRIVIAL_UNREF_FUNC\((\w+)\)', line)
+ if m:
+ text += f' {{ "{m[1]}_unref", {m[1]}_unref }},\n'
+ continue
+
return text
}
int udev_ctrl_enable_receiving(UdevCtrl *uctrl);
-UdevCtrl *udev_ctrl_ref(UdevCtrl *uctrl);
-UdevCtrl *udev_ctrl_unref(UdevCtrl *uctrl);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(UdevCtrl, udev_ctrl);
int udev_ctrl_attach_event(UdevCtrl *uctrl, sd_event *event);
int udev_ctrl_start(UdevCtrl *uctrl, udev_ctrl_handler_t callback, void *userdata);
sd_event_source *udev_ctrl_get_event_source(UdevCtrl *uctrl);
} UdevEvent;
UdevEvent* udev_event_new(sd_device *dev, UdevWorker *worker, EventMode mode);
-UdevEvent* udev_event_ref(UdevEvent *event);
-UdevEvent* udev_event_unref(UdevEvent *event);
+DECLARE_TRIVIAL_REF_UNREF_FUNC(UdevEvent, udev_event);
DEFINE_TRIVIAL_CLEANUP_FUNC(UdevEvent*, udev_event_unref);
int udev_event_execute_rules(UdevEvent *event, UdevRules *rules);