From a740fcee56bd456a759e03526df476e1791fb2bd Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 29 Apr 2015 05:25:08 +0200 Subject: Create dummy register context --- pcilib/register.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pcilib/register.c') diff --git a/pcilib/register.c b/pcilib/register.c index 586dded..f10e29b 100644 --- a/pcilib/register.c +++ b/pcilib/register.c @@ -21,8 +21,10 @@ int pcilib_add_registers(pcilib_t *ctx, size_t n, const pcilib_register_description_t *registers) { // DS: Overrride existing registers + // Registers identified by addr + offset + size + type or name pcilib_register_description_t *regs; + pcilib_register_context_t *reg_ctx; size_t size; if (!n) { @@ -37,6 +39,14 @@ int pcilib_add_registers(pcilib_t *ctx, size_t n, const pcilib_register_descript ctx->registers = regs; ctx->model_info.registers = regs; + + reg_ctx = (pcilib_register_context_t*)realloc(ctx->registers, size * sizeof(pcilib_register_context_t)); + if (!reg_ctx) return PCILIB_ERROR_MEMORY; + + memset(reg_ctx + ctx->alloc_reg, 0, (size - ctx->alloc_reg) * sizeof(pcilib_register_context_t)); + + ctx->register_ctx = reg_ctx; + ctx->alloc_reg = size; } -- cgit v1.2.3