summaryrefslogtreecommitdiff
path: root/src/mmap_notify.c
blob: 5fb71cedf2259f7058df8c0d1bb2b77594091620 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright (c) 2018 The strace developers.
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "mmap_notify.h"

struct mmap_notify_client {
	mmap_notify_fn fn;
	void *data;
	struct mmap_notify_client *next;
};

static struct mmap_notify_client *clients;

void
mmap_notify_register_client(mmap_notify_fn fn, void *data)
{
	struct mmap_notify_client *client = xmalloc(sizeof(*client));
	client->fn = fn;
	client->data = data;
	client->next = clients;
	clients = client;
}

void
mmap_notify_report(struct tcb *tcp)
{
	struct mmap_notify_client *client;

	for (client = clients; client; client = client->next)
		client->fn(tcp, client->data);
}