From 4b66ffd08c689cd2acae4bea0d411ebd7b8b5a80 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 14 Jan 2009 13:03:15 -0800 Subject: [PATCH] Use a static buffer when returning the vector value of a const. string. This patch fixes vvp to use the standard static result buffer when returning the vector value of a constant string. The previous calloc method was creating a memory leak. --- vvp/vpi_const.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index 44d7f0e05..a43b33527 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -138,16 +138,20 @@ static void string_value(vpiHandle ref, p_vpi_value vp) break; case vpiVectorVal: - vp->value.vector = (p_vpi_vecval) calloc((size+3)/4, - sizeof(s_vpi_vecval)); + vp->value.vector = (p_vpi_vecval) + need_result_buf((size+3)/4* + sizeof(s_vpi_vecval), + RBUF_VAL); uint_value = 0; vecp = vp->value.vector; + vecp->aval = vecp->bval = 0; for(int i=0; iaval |= rfp->value[i] << uint_value*8; uint_value += 1; if (uint_value > 3) { uint_value = 0; vecp += 1; + vecp->aval = vecp->bval = 0; } } break;