diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-04-29 05:25:08 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-04-29 05:25:08 +0200 |
commit | a740fcee56bd456a759e03526df476e1791fb2bd (patch) | |
tree | 150af9b0b67abee77ae304b6d20516d8673bf52a /pcilib/register.c | |
parent | 0f8c3ffba654a5b05fa509f412c0b9d9de931c69 (diff) | |
download | pcitool-a740fcee56bd456a759e03526df476e1791fb2bd.tar.gz pcitool-a740fcee56bd456a759e03526df476e1791fb2bd.tar.bz2 pcitool-a740fcee56bd456a759e03526df476e1791fb2bd.tar.xz pcitool-a740fcee56bd456a759e03526df476e1791fb2bd.zip |
Create dummy register context
Diffstat (limited to 'pcilib/register.c')
-rw-r--r-- | pcilib/register.c | 10 |
1 files changed, 10 insertions, 0 deletions
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; } |