Hari Bathini | f3b3614 | 2017-03-08 02:11:43 +0530 | [diff] [blame] | 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> |
Arnaldo Carvalho de Melo | 72f7c4d | 2017-04-19 19:06:30 -0300 | [diff] [blame^] | 14 | #include <string.h> |
Hari Bathini | f3b3614 | 2017-03-08 02:11:43 +0530 | [diff] [blame] | 15 | |
| 16 | struct 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 | |
| 34 | void namespaces__free(struct namespaces *namespaces) |
| 35 | { |
| 36 | free(namespaces); |
| 37 | } |