make use of TMALLOC()

This commit is contained in:
rlar 2012-02-09 20:46:12 +00:00
parent 2e4d4a0e02
commit d0f5ad49d1
4 changed files with 15 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2012-02-09 Robert Larice
* src/frontend/com_sysinfo.c ,
* src/frontend/mw_coms.c ,
* src/frontend/outitf.c :
make use of TMALLOC()
2012-02-09 Robert Larice
* src/main.c ,
* src/tclspice.c ,

View File

@ -217,7 +217,7 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) {
if(EOF == fgetc(file))
break;
info->osName = (char*) malloc(size * sizeof(char));
info->osName = TMALLOC(char, size);
rewind(file);
fread(info->osName, sizeof(char), size, file);
fclose(file);
@ -240,7 +240,7 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) {
break;
/* get complete string */
inStr = (char*) malloc((size+1) * sizeof(char));
inStr = TMALLOC(char, size+1);
rewind(file);
fread(inStr, sizeof(char), size, file);
inStr[size] = '\0';
@ -258,7 +258,7 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) {
if(numToEOL > 2) {
/* skip ": "*/
numToEOL-=2;
info->cpuModelName = (char*) malloc(numToEOL+1);
info->cpuModelName = TMALLOC(char, numToEOL+1);
memcpy(info->cpuModelName, modelPtr+2, numToEOL);
info->cpuModelName[numToEOL] = '\0';
}
@ -285,7 +285,7 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) {
if (isblank(*strPtr)) numProcs++;
}
info->numLogicalProcessors = numProcs;
physIDs = (tInt*) malloc(numProcs * sizeof(tInt));
physIDs = TMALLOC(tInt, numProcs);
/* get number of physical CPUs */
numProcs = 0;
@ -434,7 +434,7 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) {
size_t lengthCSD = strlen(version.szCSDVersion);
size_t lengthVer = strlen(versionStr);
info->osName = malloc(lengthVer + lengthCSD + 2);
info->osName = TMALLOC(char, lengthVer + lengthCSD + 2);
memcpy(info->osName, versionStr, lengthVer);
memcpy(info->osName + lengthVer + 1, version.szCSDVersion, lengthCSD);
info->osName[lengthVer] = ' ';

View File

@ -33,7 +33,7 @@ com_removecirc(wordlist *wl)
NG_IGNORE(wl);
/* Allocation of a temp wordlist */
wlist = (struct wordlist *)malloc(sizeof(struct wordlist));
wlist = TMALLOC(struct wordlist, 1);
if (ft_curckt == NULL) {
fprintf(cp_err, "Error: there is no circuit loaded.\n");

View File

@ -843,10 +843,10 @@ fileInit_pass2(runDesc *run)
/* Allocate Row buffer */
if (run->binary) {
rowbuflen = (size_t) (run->numData) * sizeof(double);
rowbuflen = (size_t) (run->numData);
if (run->isComplex)
rowbuflen *= 2;
rowbuf = (double *) tmalloc(rowbuflen);
rowbuf = TMALLOC(double, rowbuflen);
} else rowbuf=NULL;
return;
@ -897,7 +897,7 @@ fileEndPoint(FILE *fp, bool bin)
{
if (bin) {
/* write row buffer to file */
fwrite(rowbuf, rowbuflen, 1, fp);
fwrite(rowbuf, sizeof(double), rowbuflen, fp);
}; /* otherwise the data has already been written */
return;
}