mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
perf tools: Introduce xyarray__reset function
To zero all the xyarray contents. It will be used in following patches. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1434269985-521-2-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
ba7ecb02e7
commit
b45f65e8fd
2 changed files with 10 additions and 0 deletions
|
@ -9,11 +9,19 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
|
||||||
if (xy != NULL) {
|
if (xy != NULL) {
|
||||||
xy->entry_size = entry_size;
|
xy->entry_size = entry_size;
|
||||||
xy->row_size = row_size;
|
xy->row_size = row_size;
|
||||||
|
xy->entries = xlen * ylen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xy;
|
return xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xyarray__reset(struct xyarray *xy)
|
||||||
|
{
|
||||||
|
size_t n = xy->entries * xy->entry_size;
|
||||||
|
|
||||||
|
memset(xy->contents, 0, n);
|
||||||
|
}
|
||||||
|
|
||||||
void xyarray__delete(struct xyarray *xy)
|
void xyarray__delete(struct xyarray *xy)
|
||||||
{
|
{
|
||||||
free(xy);
|
free(xy);
|
||||||
|
|
|
@ -6,11 +6,13 @@
|
||||||
struct xyarray {
|
struct xyarray {
|
||||||
size_t row_size;
|
size_t row_size;
|
||||||
size_t entry_size;
|
size_t entry_size;
|
||||||
|
size_t entries;
|
||||||
char contents[];
|
char contents[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
|
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
|
||||||
void xyarray__delete(struct xyarray *xy);
|
void xyarray__delete(struct xyarray *xy);
|
||||||
|
void xyarray__reset(struct xyarray *xy);
|
||||||
|
|
||||||
static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
|
static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue