#include <sys/stat.h>
#include <sys/types.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/fs-handle-internal.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/optional.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/fs-handle-internal.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
-#include "fd-tracker.h"
-#include "inode.h"
+#include "fd-tracker.hpp"
+#include "inode.hpp"
/* Tracker lock must be taken by the user. */
#define TRACKED_COUNT(tracker) \
unsigned long value;
} seed = {
.lock = PTHREAD_MUTEX_INITIALIZER,
+ .initialized = false,
+ .value = 0,
};
static int match_fd(struct cds_lfht_node *node, const void *key);
static struct unsuspendable_fd *unsuspendable_fd_create(
const char *name, int fd)
{
- struct unsuspendable_fd *entry = (unsuspendable_fd *) zmalloc(sizeof(*entry));
+ struct unsuspendable_fd *entry = zmalloc<unsuspendable_fd>();
if (!entry) {
goto error;
struct fd_tracker *fd_tracker_create(const char *unlinked_file_path,
unsigned int capacity)
{
- struct fd_tracker *tracker = (fd_tracker *) zmalloc(sizeof(struct fd_tracker));
+ struct fd_tracker *tracker = zmalloc<fd_tracker>();
if (!tracker) {
goto end;
}
}
- handle = (fs_handle_tracked *) zmalloc(sizeof(*handle));
+ handle = zmalloc<fs_handle_tracked>();
if (!handle) {
goto end;
}
unsigned int active_fds;
struct unsuspendable_fd **entries;
- entries = (unsuspendable_fd **) zmalloc(fd_count * sizeof(*entries));
+ entries = calloc<unsuspendable_fd *>(fd_count);
if (!entries) {
ret = -1;
goto end;
* Maintain a local copy of fds_in as the user's callback may modify its
* contents (e.g. setting the fd(s) to -1 after close).
*/
- fds = (int *) malloc(sizeof(*fds) * fd_count);
+ fds = malloc<int>(sizeof(*fds) * fd_count);
if (!fds) {
ret = -1;
goto end;