#include <stdint.h>
#include <stdlib.h>
#include <syslog.h>

#include "sanlock_internal.h"
#include "log.h"

/* Moved from resource.c to prevent circular dependency */
void free_token(struct token *token)
{
	if (token->caw_dev_fd)
		log_debug("free_token leak caw_dev_fd %d", token->caw_dev_fd);
	if (token->caw_data)
		free(token->caw_data);
	free(token);
}

/* Moved from lockspace.c to prevent circular dependency */
void set_id_bit(int host_id, char *bitmap, char *c)
{
	char *byte = bitmap + ((host_id - 1) / 8);
	unsigned int bit = (host_id - 1) % 8;
	char mask;

	mask = 1 << bit;

	*byte |= mask;

	if (c)
		*c = *byte;
}

