do not use "my" prefix for memory functions in pluginlink

This commit is contained in:
z3APA3A 2019-08-19 12:35:36 +03:00
parent cb217d79c1
commit 336b411ea2
6 changed files with 72 additions and 72 deletions

View File

@ -68,7 +68,7 @@ int savecounters(void)
tc = tc->next;
f=NULL;
if(strcmp(tcd->comment,"ldapcounters")==0) {
tmpbuf=mypluginlink->myalloc(strlen(pat_file)+strlen(ldap_dircount)+strlen(tcd->ace->users->user));
tmpbuf=mypluginlink->malloc(strlen(pat_file)+strlen(ldap_dircount)+strlen(tcd->ace->users->user));
sprintf(tmpbuf,pat_file,ldap_dircount,tcd->ace->users->user);
f=fopen(tmpbuf,"w+b");
fseek(f,0,SEEK_SET);
@ -76,7 +76,7 @@ int savecounters(void)
(unsigned long)tcd->cleared,(unsigned long)tcd->updated);
fclose(f);
mypluginlink->myfree(tmpbuf);
mypluginlink->free(tmpbuf);
}
}
@ -194,15 +194,15 @@ int h_ldapconnect(int argc, unsigned char ** argv)
return 1;
}
ldap_serv=mypluginlink->mystrdup(argv[1]);
ldap_user=mypluginlink->mystrdup(argv[2]);
ldap_serv=mypluginlink->strdup(argv[1]);
ldap_user=mypluginlink->strdup(argv[2]);
ld = ldap_init( ldap_serv, 389 );
ldap_unbind_s(ld);
if (argc == 4)
{
ldap_pass= mypluginlink->mystrdup(argv[3]);
ldap_pass= mypluginlink->strdup(argv[3]);
}
else
{
@ -220,7 +220,7 @@ int h_access(int argc, unsigned char ** argv)
fprintf(stderr, "Error in ldapaccess: See documentation of ldapauth plugin.\n");
return 1;
}
ldap_access=mypluginlink->mystrdup(argv[1]);
ldap_access=mypluginlink->strdup(argv[1]);
return 0;
}
/* --------------------------------------------------------------------------
@ -233,7 +233,7 @@ int h_sbase(int argc, unsigned char ** argv)
fprintf(stderr, "Error in ldapsbase: See documentation of ldapauth plugin.\n");
return 1;
}
ldap_sbase=mypluginlink->mystrdup(argv[1]);
ldap_sbase=mypluginlink->strdup(argv[1]);
return 0;
}
/* --------------------------------------------------------------------------
@ -245,7 +245,7 @@ int h_userenv(int argc, unsigned char ** argv)
fprintf(stderr, "Error in ldapsbase: See documentation of ldapauth plugin.\n");
return 1;
}
ldap_userenv=mypluginlink->mystrdup(argv[1]);
ldap_userenv=mypluginlink->strdup(argv[1]);
return 0;
}
/* --------------------------------------------------------------------------
@ -309,11 +309,11 @@ int h_trafgroup(int argc, unsigned char ** argv)
bandwidth = atoi((char *)argv[4]);
/* name ldap group */
tmpbuf=mypluginlink->myalloc(strlen(pat_group)+strlen(ldap_group_attr)+strlen(argv[1]));
tmpbuf=mypluginlink->malloc(strlen(pat_group)+strlen(ldap_group_attr)+strlen(argv[1]));
sprintf(tmpbuf,pat_group,ldap_group_attr,argv[1]);
rc = ldap_search_s( ld, ldap_sbase, LDAP_SCOPE_SUBTREE,
tmpbuf, attrs, 0, &res );
mypluginlink->myfree(tmpbuf);
mypluginlink->free(tmpbuf);
rc=ldap_count_entries(ld,res);
@ -331,7 +331,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
/* -------------bandlim----------
create user list */
newuserlist = (*mypluginlink->myalloc)(sizeof (struct userlist));
newuserlist = (*mypluginlink->malloc)(sizeof (struct userlist));
if (usercaselow > 0)
#ifdef _WIN32
{ CharLower(vals[0]); }
@ -339,15 +339,15 @@ int h_trafgroup(int argc, unsigned char ** argv)
{ lower(vals[0]); }
#endif
newuserlist->user = (*mypluginlink->mystrdup)(vals[0]);
newuserlist->user = (*mypluginlink->strdup)(vals[0]);
newuserlist->next = NULL;
/*create user rule */
newace = (*mypluginlink->myalloc)(sizeof (struct ace));
newace = (*mypluginlink->malloc)(sizeof (struct ace));
memset(newace, 0, sizeof(struct ace));
newace->users = newuserlist;
newace->action = BANDLIM;
/*create user bandlim */
newbandlim =(*mypluginlink->myalloc)(sizeof (struct bandlim));
newbandlim =(*mypluginlink->malloc)(sizeof (struct bandlim));
memset(newbandlim, 0, sizeof(struct bandlim));
newbandlim->rate = bandwidth;
newbandlim->ace = newace;
@ -356,29 +356,29 @@ int h_trafgroup(int argc, unsigned char ** argv)
/* -------------counters----------
create user list */
newuserlist = (*mypluginlink->myalloc)(sizeof (struct userlist));
newuserlist = (*mypluginlink->malloc)(sizeof (struct userlist));
if (usercaselow > 0)
#ifdef _WIN32
{ CharLower(vals[0]); }
#else
{ lower(vals[0]); }
#endif
newuserlist->user = (*mypluginlink->mystrdup)(vals[0]);
newuserlist->user = (*mypluginlink->strdup)(vals[0]);
newuserlist->next = NULL;
/*create user rule */
newace = (*mypluginlink->myalloc)(sizeof (struct ace));
newace = (*mypluginlink->malloc)(sizeof (struct ace));
memset(newace, 0, sizeof(struct ace));
newace->users = newuserlist;
newace->action = COUNTIN;
/*create user counter */
newtrafcount =(*mypluginlink->myalloc)(sizeof (struct trafcount));
newtrafcount =(*mypluginlink->malloc)(sizeof (struct trafcount));
memset(newtrafcount, 0, sizeof(struct trafcount));
newtrafcount->ace = newace;
newtrafcount->type=rtype;
newtrafcount->traflim64 = traflimit;
newtrafcount->comment=(*mypluginlink->mystrdup)("ldapcounters");
newtrafcount->comment=(*mypluginlink->strdup)("ldapcounters");
newtrafcount->number=0;
tmpbuf=(*mypluginlink->myalloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
tmpbuf=(*mypluginlink->malloc)(strlen(pat_file)+strlen(ldap_dircount)+strlen(vals[0]));
sprintf(tmpbuf,pat_file,ldap_dircount,vals[0]);
f=NULL;
f=fopen(tmpbuf,"rb");
@ -396,7 +396,7 @@ int h_trafgroup(int argc, unsigned char ** argv)
newtrafcount->updated=rcounter.updated;
fclose(f);
}
mypluginlink->myfree(tmpbuf);
mypluginlink->free(tmpbuf);
newtrafcount->next = mypluginlink->conf->trafcounter;
mypluginlink->conf->trafcounter = newtrafcount;
@ -422,8 +422,8 @@ int h_attrsgroup(int argc, unsigned char ** argv)
fprintf(stderr, "Error in ldapattr: See documentation of ldapauth plugin.\n");
return 1;
}
attrs[0]=mypluginlink->mystrdup(argv[1]);
ldap_group_attr=mypluginlink->mystrdup(argv[2]);
attrs[0]=mypluginlink->strdup(argv[1]);
ldap_group_attr=mypluginlink->strdup(argv[2]);
if(argc == 4)
{ usercaselow=atoi(argv[3]); }
@ -439,7 +439,7 @@ int h_dircount(int argc, unsigned char ** argv)
fprintf(stderr, "Error in ldapdircount: See documentation of ldapauth plugin.\n");
return 1;
}
ldap_dircount=mypluginlink->mystrdup(argv[1]);
ldap_dircount=mypluginlink->strdup(argv[1]);
return 0;
}
@ -460,15 +460,15 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
if (already_loaded != 0)
{
pluginlink->myfree(ldap_access);
pluginlink->myfree(ldap_sbase);
pluginlink->myfree(ldap_serv);
pluginlink->myfree(ldap_user);
pluginlink->myfree(ldap_pass);
pluginlink->myfree(ldap_userenv);
pluginlink->myfree(ldap_dircount);
pluginlink->myfree(ldap_group_attr);
pluginlink->myfree(attrs[0]);
pluginlink->free(ldap_access);
pluginlink->free(ldap_sbase);
pluginlink->free(ldap_serv);
pluginlink->free(ldap_user);
pluginlink->free(ldap_pass);
pluginlink->free(ldap_userenv);
pluginlink->free(ldap_dircount);
pluginlink->free(ldap_group_attr);
pluginlink->free(attrs[0]);
return (0);
}

View File

@ -84,10 +84,10 @@ static void pcre_data_free(struct pcre_filter_data *pcrefd){
pthread_mutex_lock(&pcre_mutex);
pcrefd->users--;
if(!pcrefd->users){
if(pcrefd->re) pl->myfree(pcrefd->re);
if(pcrefd->re) pl->free(pcrefd->re);
if(pcrefd->acl) pl->freeacl(pcrefd->acl);
if(pcrefd->replace) pl->myfree(pcrefd->replace);
pl->myfree(pcrefd);
if(pcrefd->replace) pl->free(pcrefd->replace);
pl->free(pcrefd);
}
pthread_mutex_unlock(&pcre_mutex);
}
@ -167,7 +167,7 @@ static FILTER_ACTION pcre_filter_buffer(void *fc, struct clientparam *param, uns
}
}
tmpbuf = (*pl->myalloc)(replen);
tmpbuf = (*pl->malloc)(replen);
if(!tmpbuf) return CONTINUE;
for(target = tmpbuf, replace = pcrefd->replace; *replace; ){
if(*replace == '\\' && *(replace +1)){
@ -188,18 +188,18 @@ static FILTER_ACTION pcre_filter_buffer(void *fc, struct clientparam *param, uns
}
memcpy(target, *buf_p + ovector[1], *length_p - ovector[1]);
if((ovector[0] + replen + 1) > *bufsize_p){
newbuf = (*pl->myalloc)(ovector[0] + replen + 1);
newbuf = (*pl->malloc)(ovector[0] + replen + 1);
if(!newbuf){
(*pl->myfree)(tmpbuf);
(*pl->free)(tmpbuf);
return CONTINUE;
}
memcpy(newbuf, *buf_p, ovector[0]);
(*pl->myfree)(*buf_p);
(*pl->free)(*buf_p);
*buf_p = (unsigned char *)newbuf;
*bufsize_p = ovector[0] + replen + 1;
}
memcpy(*buf_p + ovector[0], tmpbuf, replen);
(*pl->myfree)(tmpbuf);
(*pl->free)(tmpbuf);
(*buf_p)[ovector[0] + replen] = 0;
*length_p = ovector[0] + replen;
if(ovector[0] + replen <= offset){
@ -237,7 +237,7 @@ static int h_pcre(int argc, unsigned char **argv){
if(!strncmp((char *)argv[0], "pcre_rewrite", 12)) {
int i,j;
offset = 5;
replace = pl->mystrdup((char *)argv[4]);
replace = pl->strdup((char *)argv[4]);
if(!replace) return 9;
for(i=0, j=0; replace[i]; i++, j++){
if(replace[i] == '\\'){
@ -270,19 +270,19 @@ static int h_pcre(int argc, unsigned char **argv){
if(*argv[3] && !(*argv[3] == '*' && !argv[3][1]) ){
re = pcre_compile((char *)argv[3], pcre_options, &errptr, &offset, NULL);
if(!re) {
pl->myfree(acl);
if(replace) pl->myfree(replace);
pl->free(acl);
if(replace) pl->free(replace);
return 3;
}
}
flt = pl->myalloc(sizeof(struct pcre_filter_data));
newf = pl->myalloc(sizeof(struct filter));
flt = pl->malloc(sizeof(struct pcre_filter_data));
newf = pl->malloc(sizeof(struct filter));
if(!flt || !newf) {
pl->myfree(acl);
pl->myfree(re);
if(replace) pl->myfree(replace);
if(flt) pl->myfree(flt);
pl->free(acl);
pl->free(re);
if(replace) pl->free(replace);
if(flt) pl->free(flt);
return 4;
}
memset(flt, 0, sizeof(struct pcre_filter_data));
@ -367,11 +367,11 @@ PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink,
pl = pluginlink;
pcre_options = 0;
if(!pcre_loaded){
pcre_malloc = pl->myalloc;
pcre_free = pl->myfree;
pcre_malloc = pl->malloc;
pcre_free = pl->free;
pcre_loaded = 1;
pthread_mutex_init(&pcre_mutex, NULL);
regexp_symbols[6].value = pl->myfree;
regexp_symbols[6].value = pl->free;
regexp_symbols[6].next = pl->symbols.next;
pl->symbols.next = regexp_symbols;
pcre_commandhandlers[3].next = pl->commandhandlers->next;
@ -386,7 +386,7 @@ PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink,
tmpflt = flt->next;
if(flt->data)
pcre_data_free((struct pcre_filter_data *)flt->data);
pl->myfree(flt);
pl->free(flt);
if(flt == pcre_last_filter) break;
}
}

View File

@ -131,8 +131,8 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, unsigne
if(argc < 2) return 1;
pl = pluginlink;
if(service) pl->myfree(service);
service=(unsigned char *)pl->mystrdup((char *)argv[1]);
if(service) pl->free(service);
service=(unsigned char *)pl->strdup((char *)argv[1]);
if (already_loaded) { return (0); }

View File

@ -44,7 +44,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
/*create table for old strings */
old_table=(char **)mypl->myalloc(max_count_str*sizeof(char *));
old_table=(char **)mypl->malloc(max_count_str*sizeof(char *));
memset(old_table,0,max_count_str*sizeof(char *));
/*load from file new strings */
@ -77,13 +77,13 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
cstr=cstr+(int)strlen(tmpbuf1)+1;
p = (char *)mypl->myalloc(cstr);
p = (char *)mypl->malloc(cstr);
if (pt!=NULL)
{
strcpy(p, pt);
strcat(p, tmpbuf1);
mypl->myfree(pt);
mypl->free(pt);
}
else
{ strcpy(p, tmpbuf1); }
@ -104,9 +104,9 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
}
if(pt)mypl->myfree(pt);
if(pt)mypl->free(pt);
*countloadstr=i;
if (i==0) { mypl->myfree(old_table); old_table=NULL; }
if (i==0) { mypl->free(old_table); old_table=NULL; }
return old_table;
@ -124,9 +124,9 @@ static int restore_old_table(void * v)
for(i=0; i < count_str_proxy_in_3proxy; i++){
p=mypl->proxy_table[i];
mypl->proxy_table[i]=old_proxy_table[i];
mypl->myfree(p);
mypl->free(p);
}
mypl->myfree(old_proxy_table);
mypl->free(old_proxy_table);
old_proxy_table = NULL;
}
@ -140,9 +140,9 @@ static int restore_old_table(void * v)
for(i=0; i < count_str_admin_in_3proxy; i++){
p=mypl->admin_table[i];
mypl->admin_table[i]=old_admin_table[i];
mypl->myfree(p);
mypl->free(p);
}
mypl->myfree(old_admin_table);
mypl->free(old_admin_table);
old_admin_table = NULL;
}
/*return 1 delete job, 0 no delete!!! :)*/

View File

@ -74,7 +74,7 @@ static void killtrafcorrect() {
while (p) {
d = p;
p = p->next;
pl->myfree(d);
pl->free(d);
}
}
@ -94,7 +94,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
}
return 1;
}
newitem = (struct trafcorrect *)pl->myalloc(sizeof(struct trafcorrect));
newitem = (struct trafcorrect *)pl->malloc(sizeof(struct trafcorrect));
newitem->next = NULL;
newitem->type = MULTIPLAY;
@ -112,7 +112,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
newitem->coeff = atof((char *)argv[4]);
/* ďđîâĺđęŕ íŕ ęîđđĺęňíîńňü ââîäŕ */
if ((newitem->port>65535) | (newitem->coeff<=0) | (newitem->coeff>100)) {
pl->myfree(newitem);
pl->free(newitem);
if(DBGLEVEL == 1)fprintf(stdout, "Port must be 0<p<65535 and coefficient must be 0<c<100.\n");
return 2;
}
@ -130,7 +130,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
return 1;
}
newitem = (struct trafcorrect *)pl->myalloc(sizeof(struct trafcorrect));
newitem = (struct trafcorrect *)pl->malloc(sizeof(struct trafcorrect));
newitem->next = NULL;
newitem->type = IPCORRECT;
@ -158,7 +158,7 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
}
if ((newitem->port>65535) | (newitem->psize<=0)) {
pl->myfree(newitem);
pl->free(newitem);
if(DBGLEVEL == 1)fprintf(stdout, "Port must be 0<p<65535.\n");
return 2;
}

View File

@ -62,8 +62,8 @@ static FILTER_ACTION transparent_filter_client(void *fo, struct clientparam * pa
param->sincl = param->srv->intsa;
#endif
pl->myinet_ntop(*SAFAMILY(&param->req), SAADDR(&param->req), (char *)addrbuf, sizeof(addrbuf));
if(param->hostname) pl->myfree(param->hostname);
param->hostname = pl->mystrdup(addrbuf);
if(param->hostname) pl->free(param->hostname);
param->hostname = pl->strdup(addrbuf);
param->sinsr = param->req;
return PASS;
}