]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - tools/perf/util/xyarray.c
Merge tag 'tty-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[mirror_ubuntu-eoan-kernel.git] / tools / perf / util / xyarray.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
69aad6f1
ACM
2#include "xyarray.h"
3#include "util.h"
72f7c4d2
ACM
4#include <stdlib.h>
5#include <string.h>
69aad6f1
ACM
6
7struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
8{
9 size_t row_size = ylen * entry_size;
10 struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size);
11
12 if (xy != NULL) {
13 xy->entry_size = entry_size;
14 xy->row_size = row_size;
b45f65e8 15 xy->entries = xlen * ylen;
d74be476
AK
16 xy->max_x = xlen;
17 xy->max_y = ylen;
69aad6f1
ACM
18 }
19
20 return xy;
21}
22
b45f65e8
JO
23void xyarray__reset(struct xyarray *xy)
24{
25 size_t n = xy->entries * xy->entry_size;
26
27 memset(xy->contents, 0, n);
28}
29
69aad6f1
ACM
30void xyarray__delete(struct xyarray *xy)
31{
32 free(xy);
33}