Fix a realloc size error and initialize enable_ in the dff.

The buffer reallocation in scan_format_string() was one character
too small. The enable_ pin to the dff primitive was not given an
initial value.
This commit is contained in:
Cary R 2008-02-18 12:48:36 -08:00 committed by Stephen Williams
parent 2bd13964cd
commit 528af27769
2 changed files with 4 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006 Stephen Williams (steve@icarus.com)
* Copyright (c) 2006-2008 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
@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_scanf.c,v 1.8 2007/04/16 00:09:58 steve Exp $"
#endif
/* round() is ISO C99 from math.h. This define should enable it. */
# define _ISOC99_SOURCE 1
@ -200,7 +197,7 @@ static int scan_format_string(struct byte_source*src, vpiHandle arg)
if (ch == EOF)
break;
tmp = realloc(tmp, len+1);
tmp = realloc(tmp, len+2);
tmp[len++] = ch;
ch = byte_getc(src);
@ -602,4 +599,3 @@ void sys_scanf_register()
tf_data.user_data = "$sscanf";
vpi_register_systf(&tf_data);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005 Stephen Williams (steve@icarus.com)
* Copyright (c) 2005-2008 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
@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: dff.cc,v 1.2 2005/06/22 00:04:49 steve Exp $"
#endif
# include "compile.h"
# include "schedule.h"
@ -35,6 +32,7 @@ vvp_dff::vvp_dff(bool invert_clk, bool invert_ce)
: iclk_(invert_clk), ice_(invert_ce)
{
clk_cur_ = BIT4_X;
enable_ = BIT4_X;
}
vvp_dff::~vvp_dff()