Linux Perf
xyarray.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _PERF_XYARRAY_H_
3 #define _PERF_XYARRAY_H_ 1
4 
5 #include <sys/types.h>
6 
7 struct xyarray {
8  size_t row_size;
9  size_t entry_size;
10  size_t entries;
11  size_t max_x;
12  size_t max_y;
13  char contents[];
14 };
15 
16 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
17 void xyarray__delete(struct xyarray *xy);
18 void xyarray__reset(struct xyarray *xy);
19 
20 static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
21 {
22  return &xy->contents[x * xy->row_size + y * xy->entry_size];
23 }
24 
25 static inline int xyarray__max_y(struct xyarray *xy)
26 {
27  return xy->max_y;
28 }
29 
30 static inline int xyarray__max_x(struct xyarray *xy)
31 {
32  return xy->max_x;
33 }
34 
35 #endif /* _PERF_XYARRAY_H_ */
size_t row_size
Definition: xyarray.h:8
Definition: xyarray.h:7
static void * xyarray__entry(struct xyarray *xy, int x, int y)
Definition: xyarray.h:20
static int xyarray__max_x(struct xyarray *xy)
Definition: xyarray.h:30
struct xyarray * xyarray__new(int xlen, int ylen, size_t entry_size)
Definition: xyarray.c:7
size_t max_y
Definition: xyarray.h:12
char contents[]
Definition: xyarray.h:13
size_t entry_size
Definition: xyarray.h:9
void xyarray__reset(struct xyarray *xy)
Definition: xyarray.c:23
size_t entries
Definition: xyarray.h:10
size_t max_x
Definition: xyarray.h:11
static int xyarray__max_y(struct xyarray *xy)
Definition: xyarray.h:25
void xyarray__delete(struct xyarray *xy)
Definition: xyarray.c:30