]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - tools/perf/util/namespaces.c
Merge tag 'xfs-4.13-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[mirror_ubuntu-bionic-kernel.git] / tools / perf / util / namespaces.c
CommitLineData
f3b3614a
HB
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * Copyright (C) 2017 Hari Bathini, IBM Corporation
7 */
8
9#include "namespaces.h"
10#include "util.h"
11#include "event.h"
12#include <stdlib.h>
13#include <stdio.h>
72f7c4d2 14#include <string.h>
f3b3614a
HB
15
16struct namespaces *namespaces__new(struct namespaces_event *event)
17{
18 struct namespaces *namespaces;
19 u64 link_info_size = ((event ? event->nr_namespaces : NR_NAMESPACES) *
20 sizeof(struct perf_ns_link_info));
21
22 namespaces = zalloc(sizeof(struct namespaces) + link_info_size);
23 if (!namespaces)
24 return NULL;
25
26 namespaces->end_time = -1;
27
28 if (event)
29 memcpy(namespaces->link_info, event->link_info, link_info_size);
30
31 return namespaces;
32}
33
34void namespaces__free(struct namespaces *namespaces)
35{
36 free(namespaces);
37}