Changed these to use the dbmf library for malloc/free of buffers
This commit is contained in:
@@ -41,7 +41,7 @@ LIBRARY := BSlib
|
||||
#
|
||||
# but
|
||||
#
|
||||
PROD_LIBS := BSlib Db
|
||||
PROD_LIBS := BSlib Db Com
|
||||
PROD := subtool dbLoadTemplate rdbls rdbapplist PVSserver
|
||||
|
||||
endif
|
||||
|
||||
@@ -25,9 +25,9 @@ dbLoadTemplate.o: dbLoadTemplate_lex.c
|
||||
dbLoadRecords.o: dbLoadRecords_lex.c
|
||||
subtool: dbLoadTemplate_lex.c
|
||||
|
||||
subtool: dbLoadTemplate.c dbLoadTemplate_lex.c dbVarSub.o
|
||||
subtool: dbLoadTemplate.c dbLoadTemplate_lex.c dbVarSub.o
|
||||
$(RM) $@
|
||||
$(LINK.c) $(CFLAGS) -DSUB_TOOL -o subtool dbLoadTemplate.c dbVarSub.o -s
|
||||
$(LINK.c) $(CFLAGS) -DSUB_TOOL -o subtool dbLoadTemplate.c dbVarSub.o -s
|
||||
|
||||
clean::
|
||||
@$(RM) dbLoadTemplate_lex.c dbLoadTemplate.c dbLoadRecords_lex.c \
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dbVarSub.h"
|
||||
#include <dbStaticLib.h>
|
||||
#include <epicsVersion.h>
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbmf.h"
|
||||
#include "epicsVersion.h"
|
||||
|
||||
static char subst_buffer[VAR_MAX_SUB_SIZE];
|
||||
static int subst_used;
|
||||
@@ -61,6 +62,7 @@ static void sub_pvname(char*,char*);
|
||||
static DBENTRY* pdbentry;
|
||||
extern struct dbBase *pdbbase;
|
||||
#endif
|
||||
static void* handle=NULL;
|
||||
|
||||
%}
|
||||
|
||||
@@ -90,9 +92,9 @@ database: DATABASE d_head d_body
|
||||
;
|
||||
|
||||
d_head: O_PAREN WORD C_PAREN
|
||||
{ free($2); }
|
||||
{ dbmfFree(handle,$2); }
|
||||
| O_PAREN WORD COMMA VALUE C_PAREN
|
||||
{ free($2); free($4); }
|
||||
{ dbmfFree(handle,$2); dbmfFree(handle,$4); }
|
||||
;
|
||||
|
||||
d_body: O_BRACE nowhere_records db_components C_BRACE
|
||||
@@ -126,7 +128,7 @@ applic: APPL O_PAREN VALUE C_PAREN
|
||||
fprintf(stderr,"dbDoSubst failed\n");
|
||||
#ifdef vxWorks
|
||||
an->name=strdup(subst_buffer);
|
||||
free($3);
|
||||
dbmfFree(handle,$3);
|
||||
#else
|
||||
printf("\napplication(\"%s\")\n",subst_buffer);
|
||||
#endif
|
||||
@@ -161,12 +163,12 @@ record: RECORD r_head r_body
|
||||
r_head: O_PAREN WORD COMMA WORD C_PAREN
|
||||
{
|
||||
sub_pvname($2,$4);
|
||||
free($2); free($4);
|
||||
dbmfFree(handle,$2); dbmfFree(handle,$4);
|
||||
}
|
||||
| O_PAREN WORD COMMA VALUE C_PAREN
|
||||
{
|
||||
sub_pvname($2,$4);
|
||||
free($2); free($4);
|
||||
dbmfFree(handle,$2); dbmfFree(handle,$4);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -206,7 +208,7 @@ field: FIELD O_PAREN WORD COMMA VALUE C_PAREN
|
||||
printf("\n\t\tfield(%s, \"%s\")",$<Str>3,$<Str>5);
|
||||
#endif
|
||||
}
|
||||
free($3); free($5);
|
||||
dbmfFree(handle,$3); dbmfFree(handle,$5);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -222,7 +224,7 @@ char *str;
|
||||
static char* strdup(char* x)
|
||||
{
|
||||
char* c;
|
||||
c=(char*)malloc(strlen(x)+1);
|
||||
c=(char*)dbmfMalloc(handle,strlen(x)+1);
|
||||
strcpy(c,x);
|
||||
return c;
|
||||
}
|
||||
@@ -264,6 +266,7 @@ int dbLoadRecords(char* pfilename, char* pattern)
|
||||
{
|
||||
yyin=fp;
|
||||
is_not_inited=0;
|
||||
handle=dbmfInit(55,1,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -16,9 +16,9 @@ value [a-zA-Z0-9_\,\^~\./\*#\[\]%: ;!|\'\-&\(\)@\?\+<>=\$\{\}]
|
||||
"nowhere" { return(NOWHERE); }
|
||||
"application" { return(APPL); }
|
||||
|
||||
\"{value}*\" { yylval.Str=(char *)malloc(strlen(yytext)+1); strcpy(yylval.Str,yytext+1); yylval.Str[strlen(yylval.Str)-1] = '\0'; return(VALUE); }
|
||||
\"{value}*\" { yylval.Str=(char *)dbmfMalloc(handle,strlen(yytext)+1); strcpy(yylval.Str,yytext+1); yylval.Str[strlen(yylval.Str)-1] = '\0'; return(VALUE); }
|
||||
|
||||
{pvname}+ { yylval.Str=(char *)malloc(strlen(yytext)+1); strcpy(yylval.Str,yytext); return(WORD); }
|
||||
{pvname}+ { yylval.Str=(char *)dbmfMalloc(handle,strlen(yytext)+1); strcpy(yylval.Str,yytext); return(WORD); }
|
||||
|
||||
"{" { return(O_BRACE); }
|
||||
"}" { return(C_BRACE); }
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dbVarSub.h"
|
||||
#include <epicsVersion.h>
|
||||
#include "dbmf.h"
|
||||
#include "epicsVersion.h"
|
||||
|
||||
static int line_num;
|
||||
static int yyerror();
|
||||
@@ -52,6 +53,7 @@ static char sub_collect[VAR_MAX_VAR_STRING];
|
||||
static char** vars;
|
||||
static char* db_file_name = (char*)NULL;
|
||||
static int var_count,sub_count;
|
||||
static void* handle=NULL;
|
||||
|
||||
%}
|
||||
|
||||
@@ -145,7 +147,7 @@ sub: WORD O_BRACE vals C_BRACE
|
||||
sub_it();
|
||||
#endif
|
||||
|
||||
free($1);
|
||||
dbmfFree(handle,$1);
|
||||
sub_collect[0]='\0';
|
||||
sub_count=0;
|
||||
}
|
||||
@@ -181,7 +183,7 @@ val: QUOTE
|
||||
strcat(sub_collect,"=\"");
|
||||
strcat(sub_collect,$1);
|
||||
strcat(sub_collect,"\",");
|
||||
free($1);
|
||||
dbmfFree(handle,$1);
|
||||
sub_count++;
|
||||
}
|
||||
}
|
||||
@@ -193,7 +195,7 @@ val: QUOTE
|
||||
strcat(sub_collect,"=");
|
||||
strcat(sub_collect,$1);
|
||||
strcat(sub_collect,",");
|
||||
free($1);
|
||||
dbmfFree(handle,$1);
|
||||
sub_count++;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +220,7 @@ var_sub: WORD O_BRACE sub_pats C_BRACE
|
||||
sub_it();
|
||||
#endif
|
||||
|
||||
free($1);
|
||||
dbmfFree(handle,$1);
|
||||
sub_collect[0]='\0';
|
||||
sub_count=0;
|
||||
}
|
||||
@@ -252,7 +254,7 @@ sub_pat: WORD EQUALS WORD
|
||||
strcat(sub_collect,"=");
|
||||
strcat(sub_collect,$3);
|
||||
strcat(sub_collect,",");
|
||||
free($1); free($3);
|
||||
dbmfFree(handle,$1); dbmfFree(handle,$3);
|
||||
sub_count++;
|
||||
}
|
||||
| WORD EQUALS QUOTE
|
||||
@@ -261,7 +263,7 @@ sub_pat: WORD EQUALS WORD
|
||||
strcat(sub_collect,"=\"");
|
||||
strcat(sub_collect,$3);
|
||||
strcat(sub_collect,"\",");
|
||||
free($1); free($3);
|
||||
dbmfFree(handle,$1); dbmfFree(handle,$3);
|
||||
sub_count++;
|
||||
}
|
||||
;
|
||||
@@ -305,6 +307,7 @@ int dbLoadTemplate(char* sub_file)
|
||||
{
|
||||
yyin=fp;
|
||||
is_not_inited=0;
|
||||
handle=dbmfInit(55,1,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -14,9 +14,9 @@ par [\"\']
|
||||
"file" { return(DBFILE); }
|
||||
"=" { return(EQUALS); }
|
||||
|
||||
{par}{value}*{par} { yylval.Str=(char *)malloc(strlen(yytext)+1); strcpy(yylval.Str,yytext+1); yylval.Str[strlen(yylval.Str)-1] = '\0'; return(QUOTE); }
|
||||
{par}{value}*{par} { yylval.Str=(char*)dbmfMalloc(handle,strlen(yytext)+1); strcpy(yylval.Str,yytext+1); yylval.Str[strlen(yylval.Str)-1] = '\0'; return(QUOTE); }
|
||||
|
||||
{word}+ { yylval.Str=(char *)malloc(strlen(yytext)+1); strcpy(yylval.Str,yytext); return(WORD); }
|
||||
{word}+ { yylval.Str=(char*)dbmfMalloc(handle,strlen(yytext)+1); strcpy(yylval.Str,yytext); return(WORD); }
|
||||
|
||||
"{" { return(O_BRACE); }
|
||||
"}" { return(C_BRACE); }
|
||||
|
||||
@@ -37,8 +37,9 @@
|
||||
#include <memLib.h>
|
||||
#endif
|
||||
|
||||
#include <dbVarSub.h>
|
||||
#include <dbStaticLib.h>
|
||||
#include "dbmf.h"
|
||||
#include "dbVarSub.h"
|
||||
#include "dbStaticLib.h"
|
||||
|
||||
static int subst_total;
|
||||
static struct var_sub *subst = (struct var_sub*)NULL;
|
||||
@@ -49,7 +50,7 @@ static char* get_sub(char*, char*);
|
||||
|
||||
/* ------------------ variable substitution routines --------------*/
|
||||
#ifdef vxWorks
|
||||
static char* strdup(char*p) { return strcpy((char*)malloc(strlen(p)+1),p); }
|
||||
static char* strdup(char*p) { return strcpy((char*)dbmfMalloc(NULL,strlen(p)+1),p); }
|
||||
#endif
|
||||
|
||||
void dbFreeSubst()
|
||||
|
||||
Reference in New Issue
Block a user