mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 17:55:20 +07:00
d74be47673
Save the original array dimensions in xyarrays, so that users can retrieve them later. Add some inline functions to access these fields. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/20170811232634.30465-1-andi@firstfloor.org [ As noticed by Jiri, fix up namespacing: xy__method() -> xyarray__method() ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
33 lines
603 B
C
33 lines
603 B
C
#include "xyarray.h"
|
|
#include "util.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
|
|
{
|
|
size_t row_size = ylen * entry_size;
|
|
struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size);
|
|
|
|
if (xy != NULL) {
|
|
xy->entry_size = entry_size;
|
|
xy->row_size = row_size;
|
|
xy->entries = xlen * ylen;
|
|
xy->max_x = xlen;
|
|
xy->max_y = ylen;
|
|
}
|
|
|
|
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)
|
|
{
|
|
free(xy);
|
|
}
|