mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Replace memcpy with assignment where appropriate
This commit is contained in:
1 parent
3cc9796583
commit
13a7d6be11
8 files changed
+45
-41
No files matched your search
+15
-13
@@ -26,7 +26,7 @@ void * threadfunc (void *p) {
|
||||
continue;
|
||||
}
|
||||
#ifndef WITHMAIN
|
||||
memcpy(¶m->req, ¶m->sinsr, size);
|
||||
param->req = param->sinsr;
|
||||
if(param->srv->acl) param->res = checkACL(param);
|
||||
if(param->res){
|
||||
param->srv->logfunc(param, "Connect back ACL failed");
|
||||
@@ -240,7 +240,10 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
struct sockaddr_in6 sa6;
|
||||
memset(&sa6, 0, sizeof(sa6));
|
||||
error = !getip46(46, argv[i]+2, (struct sockaddr *)&sa6);
|
||||
if(!error) memcpy((*SAFAMILY(&sa6)==AF_INET)?(void *)&srv.extsa:(void *)&srv.extsa6, &sa6, sizeof(sa6));
|
||||
if(!error) {
|
||||
if (*SAFAMILY(&sa6)==AF_INET) srv.extsa = sa6;
|
||||
else srv.extsa6 = sa6;
|
||||
}
|
||||
#else
|
||||
error = !getip46(46, argv[i]+2, (struct sockaddr *)&srv.extsa);
|
||||
#endif
|
||||
@@ -386,7 +389,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
if(! (newparam = myalloc (sizeof(defparam)))){
|
||||
return 2;
|
||||
};
|
||||
memcpy(newparam, &defparam, sizeof(defparam));
|
||||
*newparam = defparam;
|
||||
return((*srv.pf)((void *)newparam)? 1:0);
|
||||
|
||||
}
|
||||
@@ -621,7 +624,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
usleep(SLEEPTIME);
|
||||
continue;
|
||||
};
|
||||
memcpy(newparam, &defparam, sizeof(defparam));
|
||||
*newparam = defparam;
|
||||
if(defparam.hostname)newparam->hostname=strdup(defparam.hostname);
|
||||
clearstat(newparam);
|
||||
if(!isudp) newparam->clisock = new_sock;
|
||||
@@ -721,10 +724,10 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
||||
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
||||
*SAFAMILY(¶m->req) = *SAFAMILY(¶m->sinsl) = *SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->sincr) = *SAFAMILY(¶m->sincl) = AF_INET;
|
||||
pthread_mutex_init(&srv->counter_mutex, NULL);
|
||||
memcpy(&srv->intsa, &conf.intsa, sizeof(srv->intsa));
|
||||
memcpy(&srv->extsa, &conf.extsa, sizeof(srv->extsa));
|
||||
srv->intsa = conf.intsa;
|
||||
srv->extsa = conf.extsa;
|
||||
#ifndef NOIPV6
|
||||
memcpy(&srv->extsa6, &conf.extsa6, sizeof(srv->extsa6));
|
||||
srv->extsa6 = conf.extsa6;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -748,13 +751,12 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
|
||||
*SAFAMILY(¶m->sinsl) = AF_INET;
|
||||
*SAFAMILY(¶m->sinsr) = AF_INET;
|
||||
*SAFAMILY(¶m->req) = AF_INET;
|
||||
memcpy(¶m->sincr, &srv->intsa, sizeof(param->sincr));
|
||||
memcpy(¶m->sincl, &srv->intsa, sizeof(param->sincl));
|
||||
param->sincr = param->sincl = srv->intsa;
|
||||
#ifndef NOIPV6
|
||||
memcpy(¶m->sinsr, (srv->family == 6 || srv->family == 64)? (void *)&srv->extsa6: (void *)&srv->extsa, sizeof(param->sinsr));
|
||||
#else
|
||||
memcpy(¶m->sinsr, &srv->extsa, sizeof(param->sinsr));
|
||||
if (srv->family == 6 || srv->family == 64) param->sinsr = srv->extsa6;
|
||||
else
|
||||
#endif
|
||||
param->sinsr = srv->extsa;
|
||||
}
|
||||
|
||||
void srvfree(struct srvparam * srv){
|
||||
@@ -911,7 +913,7 @@ void copyfilter (struct filter *filter, struct srvparam *srv){
|
||||
|
||||
if(!filter->filter_open || !(data = (*filter->filter_open)(filter->data, srv))) continue;
|
||||
|
||||
memcpy(srv->filter + srv->nfilters, filter, sizeof(struct filter));
|
||||
srv->filter[srv->nfilters] = *filter;
|
||||
srv->filter[srv->nfilters].data = data;
|
||||
if(srv->nfilters>0)srv->filter[srv->nfilters - 1].next = srv->filter + srv->nfilters;
|
||||
srv->nfilters++;
|
||||
|
||||
Reference in new issue
Block a user