Not all compilers support dynamic array creation (array[<variable>]).
gcc supports creating an array with a run time defined size. The SunPro compiler for OpenSolaris does not. This patch converts the array creation to use conventional (malloc based) array creation.
This commit is contained in:
parent
42bc41ca5b
commit
1be00e0322
|
|
@ -1124,14 +1124,19 @@ static char* PV_get_str(int code, vpiHandle ref)
|
|||
case vpiName:
|
||||
case vpiFullName: {
|
||||
const char*nm = vpi_get_str(code, rfp->parent);
|
||||
char full[1024+strlen(nm)];
|
||||
sprintf(full, "%s[%d:%d]", nm, (int)vpi_get(vpiLeftRange, ref),
|
||||
(int)vpi_get(vpiRightRange, ref));
|
||||
return simple_set_rbuf_str(full);
|
||||
size_t len = 256+strlen(nm);
|
||||
char *full = (char *) malloc(len);
|
||||
snprintf(full, len, "%s[%d:%d]", nm,
|
||||
(int)vpi_get(vpiLeftRange, ref),
|
||||
(int)vpi_get(vpiRightRange, ref));
|
||||
full[len-1] = 0;
|
||||
char *res = simple_set_rbuf_str(full);
|
||||
free(full);
|
||||
return res;
|
||||
}
|
||||
|
||||
default:
|
||||
fprintf(stderr, "PV_get_str: property %d is unknown\n", code);
|
||||
fprintf(stderr, "PV_get_str: property %d is unknown.\n", code);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue