From 4290277dc72acf4f1ecf89af6ea89092ae98d60a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 6 Aug 2008 22:00:39 +0000 Subject: [PATCH] Replaced sizeofTypes[] with dbValueSize(). --- src/rec/subArrayRecord.c | 9 +++------ src/rec/waveformRecord.c | 11 +++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/rec/subArrayRecord.c b/src/rec/subArrayRecord.c index a391d8e32..098b7671c 100644 --- a/src/rec/subArrayRecord.c +++ b/src/rec/subArrayRecord.c @@ -91,9 +91,6 @@ struct sadset { /* subArray dset */ DEVSUPFUN read_sa; /*returns: (-1,0)=>(failure,success)*/ }; -/*sizes of field types*/ -static int sizeofTypes[] = {MAX_STRING_SIZE,1,1,2,2,4,4,4,8,2}; - static void monitor(subArrayRecord *psa); static long readValue(subArrayRecord *psa); @@ -107,8 +104,8 @@ static long init_record(subArrayRecord *psa, int pass) if (psa->malm <= 0) psa->malm = 1; if (psa->ftvl > DBF_ENUM) - psa->ftvl = 2; - psa->bptr = calloc(psa->malm, sizeofTypes[psa->ftvl]); + psa->ftvl = DBF_UCHAR; + psa->bptr = calloc(psa->malm, dbValueSize(psa->ftvl)); psa->nord = 0; return 0; } @@ -171,7 +168,7 @@ static long cvt_dbaddr(DBADDR *paddr) paddr->pfield = psa->bptr; paddr->no_elements = psa->malm; paddr->field_type = psa->ftvl; - paddr->field_size = sizeofTypes[psa->ftvl]; + paddr->field_size = dbValueSize(psa->ftvl); paddr->dbr_field_type = psa->ftvl; return 0; diff --git a/src/rec/waveformRecord.c b/src/rec/waveformRecord.c index 137cff2e6..afd21f872 100644 --- a/src/rec/waveformRecord.c +++ b/src/rec/waveformRecord.c @@ -83,8 +83,7 @@ struct wfdset { /* waveform dset */ DEVSUPFUN get_ioint_info; DEVSUPFUN read_wf; /*returns: (-1,0)=>(failure,success)*/ }; -/*sizes of field types*/ -static int sizeofTypes[] = {MAX_STRING_SIZE,1,1,2,2,4,4,4,8,2}; + static void monitor(waveformRecord *); static long readValue(waveformRecord *); @@ -96,9 +95,9 @@ static long init_record(waveformRecord *pwf, int pass) if (pwf->nelm <= 0) pwf->nelm = 1; if (pwf->ftvl > DBF_ENUM) - pwf->ftvl = 2; - pwf->bptr = calloc(pwf->nelm, sizeofTypes[pwf->ftvl]); - if (pwf->nelm==1) { + pwf->ftvl = DBF_UCHAR; + pwf->bptr = calloc(pwf->nelm, dbValueSize(pwf->ftvl)); + if (pwf->nelm == 1) { pwf->nord = 1; } else { pwf->nord = 0; @@ -163,7 +162,7 @@ static long cvt_dbaddr(DBADDR *paddr) paddr->pfield = pwf->bptr; paddr->no_elements = pwf->nelm; paddr->field_type = pwf->ftvl; - paddr->field_size = sizeofTypes[pwf->ftvl]; + paddr->field_size = dbValueSize(pwf->ftvl); paddr->dbr_field_type = pwf->ftvl; return 0;