Fix wrecked rbuf in vpi_get_str of signals and memories.

This commit is contained in:
steve 2002-09-11 16:06:57 +00:00
parent 33f462fdf6
commit 0277035496
2 changed files with 18 additions and 6 deletions

View File

@ -27,7 +27,7 @@
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704. * Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_memory.cc,v 1.18 2002/08/12 01:35:09 steve Exp $" #ident "$Id: vpi_memory.cc,v 1.19 2002/09/11 16:06:57 steve Exp $"
#endif #endif
# include "vpi_priv.h" # include "vpi_priv.h"
@ -109,20 +109,23 @@ static char* memory_get_str(int code, vpiHandle ref)
struct __vpiMemory*rfp = (struct __vpiMemory*)ref; struct __vpiMemory*rfp = (struct __vpiMemory*)ref;
char *bn = vpi_get_str(vpiFullName, &rfp->scope->base); char *bn = strdup(vpi_get_str(vpiFullName, &rfp->scope->base));
char *nm = memory_name(rfp->mem); char *nm = memory_name(rfp->mem);
char *rbuf = need_result_buf(strlen(bn) + strlen(nm) + 1, RBUF_STR); char *rbuf = need_result_buf(strlen(bn) + strlen(nm) + 2, RBUF_STR);
switch (code) { switch (code) {
case vpiFullName: case vpiFullName:
sprintf(rbuf, "%s.%s", bn, nm); sprintf(rbuf, "%s.%s", bn, nm);
free(bn);
return rbuf; return rbuf;
case vpiName: case vpiName:
strcpy(rbuf, nm); strcpy(rbuf, nm);
free(bn);
return rbuf; return rbuf;
} }
free(bn);
return 0; return 0;
} }
@ -580,6 +583,9 @@ vpiHandle vpip_make_memory(vvp_memory_t mem)
/* /*
* $Log: vpi_memory.cc,v $ * $Log: vpi_memory.cc,v $
* Revision 1.19 2002/09/11 16:06:57 steve
* Fix wrecked rbuf in vpi_get_str of signals and memories.
*
* Revision 1.18 2002/08/12 01:35:09 steve * Revision 1.18 2002/08/12 01:35:09 steve
* conditional ident string using autoconfig. * conditional ident string using autoconfig.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_signal.cc,v 1.48 2002/09/10 02:27:11 steve Exp $" #ident "$Id: vpi_signal.cc,v 1.49 2002/09/11 16:06:57 steve Exp $"
#endif #endif
/* /*
@ -110,22 +110,25 @@ static char* signal_get_str(int code, vpiHandle ref)
struct __vpiSignal*rfp = (struct __vpiSignal*)ref; struct __vpiSignal*rfp = (struct __vpiSignal*)ref;
char *bn = vpi_get_str(vpiFullName, &rfp->scope->base); char *bn = strdup(vpi_get_str(vpiFullName, &rfp->scope->base));
char *nm = (char*)rfp->name; char *nm = (char*)rfp->name;
char *rbuf = need_result_buf(strlen(bn) + strlen(nm) + 1, RBUF_STR); char *rbuf = need_result_buf(strlen(bn) + strlen(nm) + 2, RBUF_STR);
switch (code) { switch (code) {
case vpiFullName: case vpiFullName:
sprintf(rbuf, "%s.%s", bn, nm); sprintf(rbuf, "%s.%s", bn, nm);
free(bn);
return rbuf; return rbuf;
case vpiName: case vpiName:
strcpy(rbuf, nm); strcpy(rbuf, nm);
free(bn);
return rbuf; return rbuf;
} }
free(bn);
return 0; return 0;
} }
@ -719,6 +722,9 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
/* /*
* $Log: vpi_signal.cc,v $ * $Log: vpi_signal.cc,v $
* Revision 1.49 2002/09/11 16:06:57 steve
* Fix wrecked rbuf in vpi_get_str of signals and memories.
*
* Revision 1.48 2002/09/10 02:27:11 steve * Revision 1.48 2002/09/10 02:27:11 steve
* Actually set strength pointer when getting strength val. * Actually set strength pointer when getting strength val.
* *