本文整理汇总了C++中Clone函数的典型用法代码示例。如果您正苦于以下问题:C++ Clone函数的具体用法?C++ Clone怎么用?C++ Clone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Clone函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FiniteSitesDFE
FiniteSitesDFE(Random & random, DFE dfe, int L): dfe(dfe), U0(dfe.U0), L(L), draw_label(0,L-1), fitness_effects(L,1), sign_flips(L,false){
for(auto & W : fitness_effects){
W = dfe.get_fitness_effect(random, Clone());
}
};
开发者ID:benjaminhgood,项目名称:ltee_inference,代码行数:6,代码来源:dfe.hpp
示例2: RouteTrackingMain
// Routing table tracking main
void RouteTrackingMain(SESSION *s)
{
ROUTE_TRACKING *t;
UINT64 now;
ROUTE_TABLE *table;
ROUTE_ENTRY *rs;
bool changed = false;
bool check = false;
bool any_modified = false;
// Validate arguments
if (s == NULL)
{
return;
}
if (s->ClientModeAndUseVLan == false)
{
return;
}
// Get the state
t = ((VLAN *)s->PacketAdapter->Param)->RouteState;
if (t == NULL)
{
return;
}
// Current time
PROBE_STR("RouteTrackingMain 1");
now = Tick64();
if (t->RouteChange != NULL)
{
if (t->NextRouteChangeCheckTime == 0 ||
t->NextRouteChangeCheckTime <= now)
{
t->NextRouteChangeCheckTime = now + 1000ULL;
check = IsRouteChanged(t->RouteChange);
if (check)
{
Debug("*** Routing Table Changed ***\n");
t->NextTrackingTime = 0;
}
}
}
if (t->NextTrackingTime != 0 && t->NextTrackingTime > now)
{
if (s->UseUdpAcceleration && s->UdpAccel != NULL && s->UdpAccel->NatT_IP_Changed)
{
// Check always if the IP address of the NAT-T server has changed
}
else
{
PROBE_STR("RouteTrackingMain 2");
return;
}
}
PROBE_STR("RouteTrackingMain 3");
if (s->UseUdpAcceleration && s->UdpAccel != NULL)
{
IP nat_t_ip;
s->UdpAccel->NatT_IP_Changed = false;
Zero(&nat_t_ip, sizeof(nat_t_ip));
Lock(s->UdpAccel->NatT_Lock);
{
Copy(&nat_t_ip, &s->UdpAccel->NatT_IP, sizeof(IP));
}
Unlock(s->UdpAccel->NatT_Lock);
// Add a route to the NAT-T server
if (IsZeroIp(&nat_t_ip) == false)
{
if (t->RouteToNatTServer == NULL)
{
if (t->RouteToEight != NULL)
{
ROUTE_ENTRY *e = Clone(t->RouteToEight, sizeof(ROUTE_ENTRY));
char ip_str[64];
char ip_str2[64];
Copy(&e->DestIP, &nat_t_ip, sizeof(IP));
e->Metric = e->OldIfMetric;
IPToStr(ip_str, sizeof(ip_str), &e->DestIP);
IPToStr(ip_str2, sizeof(ip_str2), &e->GatewayIP);
t->RouteToNatTServer = e;
if (AddRouteEntry(t->RouteToNatTServer))
{
Debug("Adding Static Route to %s via %s metric %u: ok.\n", ip_str, ip_str2, e->Metric);
}
else
{
//.........这里部分代码省略.........
开发者ID:m-a-n-a-v,项目名称:SoftEtherVPN_Stable,代码行数:101,代码来源:VLanWin32.c
示例3: Clone
const CImageAttribute& CImageAttribute::operator=(const CImageAttribute& image)
{
Clone(image);
return *this;
}
开发者ID:baijiazhao,项目名称:DuiLib_Redrain,代码行数:5,代码来源:UIImageAttribute.cpp
示例4: raise_warning
Object c_Closure::t_bindto(const Variant& newthis, const Variant& scope) {
if (RuntimeOption::RepoAuthoritative &&
RuntimeOption::EvalAllowScopeBinding) {
raise_warning("Closure binding is not supported in RepoAuthoritative mode");
return Object{};
}
auto const cls = getVMClass();
auto const invoke = cls->getCachedInvoke();
ObjectData* od = nullptr;
if (newthis.isObject()) {
if (invoke->isStatic()) {
raise_warning("Cannot bind an instance to a static closure");
} else {
od = newthis.getObjectData();
}
} else if (!newthis.isNull()) {
raise_warning("Closure::bindto() expects parameter 1 to be object");
return Object{};
}
auto const curscope = invoke->cls();
auto newscope = curscope;
if (scope.isObject()) {
newscope = scope.getObjectData()->getVMClass();
} else if (scope.isString()) {
auto const className = scope.getStringData();
if (!className->equal(s_static.get())) {
newscope = Unit::loadClass(className);
if (!newscope) {
raise_warning("Class '%s' not found", className->data());
return Object{};
}
}
} else if (scope.isNull()) {
newscope = nullptr;
} else {
raise_warning("Closure::bindto() expects parameter 2 "
"to be string or object");
return Object{};
}
if (od && !newscope) {
// Bound closures should be scoped. If no scope is specified, scope it to
// the Closure class.
newscope = static_cast<Class*>(c_Closure::classof());
}
bool thisNotOfCtx = od && !od->getVMClass()->classof(newscope);
if (!RuntimeOption::EvalAllowScopeBinding) {
if (newscope != curscope) {
raise_warning("Re-binding closure scopes is disabled");
return Object{};
}
if (thisNotOfCtx) {
raise_warning("Binding to objects not subclassed from closure "
"context is disabled");
return Object{};
}
}
c_Closure* clone = Clone(this);
clone->setClass(nullptr);
Attr curattrs = invoke->attrs();
Attr newattrs = static_cast<Attr>(curattrs & ~AttrHasForeignThis);
if (od) {
od->incRefCount();
clone->setThis(od);
if (thisNotOfCtx) {
// If the bound $this is not a subclass of the context class, then we
// have to pessimize translation.
newattrs |= AttrHasForeignThis;
}
} else if (newscope) {
// If we attach a scope to a function with no bound $this we need to make
// the function static.
newattrs |= AttrStatic;
clone->setClass(newscope);
}
// If we are changing either the scope or the attributes of the closure, we
// need to re-scope its Closure subclass.
if (newscope != curscope || newattrs != curattrs) {
assert(newattrs != AttrNone);
auto newcls = cls->rescope(newscope, newattrs);
clone->setVMClass(newcls);
}
return Object(clone);
}
开发者ID:nadanomics,项目名称:hhvm,代码行数:99,代码来源:ext_closure.cpp
示例5: Clone
/**
* This method creates a copy of the current Message. It allocates the new one
* from the same Message Poll as the original Message and copies a full payload.
*
* @returns A pointer to the message or NULL if insufficient message buffers are available.
*/
Message *Clone(void) const { return Clone(GetLength()); };
开发者ID:nandojve,项目名称:openthread,代码行数:7,代码来源:message.hpp
示例6: Clone
Stack::Stack(const Stack& obj)
{
stack = nullptr;
Clone(obj);
}
开发者ID:ArtyomLinnik,项目名称:Study,代码行数:5,代码来源:stack.cpp
示例7: Clone
void CSL_EfTInt::Apply(MSL_ExprEnv& aEnv, vector<string>& aArgs, vector<string>::iterator& aArgr, CSL_ExprBase& aArg, CSL_ExprBase*& aRes, const string& aReqType)
{
aRes = Clone();
aRes->AcceptArg();
aRes->SetData(aArg.Data());
}
开发者ID:yborisovstc,项目名称:fapws,代码行数:6,代码来源:deslbase.cpp
示例8: skiplightreweightdraw
void skiplightreweightdraw()
{
float beta = 0.045;//110/50 = 0.28;//FEXGSP = 0.4
float gamma = 1.182;//110/50 = 1.24;//FEXGSP = 0.4
auto f= new TFile("skiplightreweight.root");
auto h12all = (TH1F *)f->Get("h12all");
auto h12fcr = (TH1F *)f->Get("h12fcr");
auto h12fex = (TH1F *)f->Get("h12fex");
auto h12gsp = (TH1F *)f->Get("h12gsp");
auto hSLall = (TH1F *)f->Get("hSLall");
auto hSLfcr = (TH1F *)f->Get("hSLfcr");
auto hSLfex = (TH1F *)f->Get("hSLfex");
auto hSLgsp = (TH1F *)f->Get("hSLgsp");
auto h12data = (TH1F *)f->Get("h12data");
auto hSLdata = (TH1F *)f->Get("hSLdata");
auto h12dphiall = (TH1F *)f->Get("h12dphiall");
auto h12dphifcr = (TH1F *)f->Get("h12dphifcr");
auto h12dphifex = (TH1F *)f->Get("h12dphifex");
auto h12dphigsp = (TH1F *)f->Get("h12dphigsp");
auto hSLdphiall = (TH1F *)f->Get("hSLdphiall");
auto hSLdphifcr = (TH1F *)f->Get("hSLdphifcr");
auto hSLdphifex = (TH1F *)f->Get("hSLdphifex");
auto hSLdphigsp = (TH1F *)f->Get("hSLdphigsp");
auto h12dphidata = (TH1F *)f->Get("h12dphidata");
auto hSLdphidata = (TH1F *)f->Get("hSLdphidata");
auto h12dphiNSall = (TH1F *)f->Get("h12dphiNSall");
auto h12dphiNSfcr = (TH1F *)f->Get("h12dphiNSfcr");
auto h12dphiNSfex = (TH1F *)f->Get("h12dphiNSfex");
auto h12dphiNSgsp = (TH1F *)f->Get("h12dphiNSgsp");
auto hSLdphiNSall = (TH1F *)f->Get("hSLdphiNSall");
auto hSLdphiNSfcr = (TH1F *)f->Get("hSLdphiNSfcr");
auto hSLdphiNSfex = (TH1F *)f->Get("hSLdphiNSfex");
auto hSLdphiNSgsp = (TH1F *)f->Get("hSLdphiNSgsp");
auto h12dphiNSdata = (TH1F *)f->Get("h12dphiNSdata");
auto hSLdphiNSdata = (TH1F *)f->Get("hSLdphiNSdata");
auto h12ordall = (TH1F *)f->Get("h12ordall");
auto h12ordfcr = (TH1F *)f->Get("h12ordfcr");
auto h12ordfex = (TH1F *)f->Get("h12ordfex");
auto h12ordgsp = (TH1F *)f->Get("h12ordgsp");
auto hSLordall = (TH1F *)f->Get("hSLordall");
auto hSLordfcr = (TH1F *)f->Get("hSLordfcr");
auto hSLordfex = (TH1F *)f->Get("hSLordfex");
auto hSLordgsp = (TH1F *)f->Get("hSLordgsp");
auto h12orddata = (TH1F *)f->Get("h12orddata");
auto hSLorddata = (TH1F *)f->Get("hSLorddata");
auto h12reweighted = (TH1F *)h12all->Clone("h12reweighted");
auto hSLreweighted = (TH1F *)hSLall->Clone("hSLreweighted");
h12reweighted->Reset();h12reweighted->SetTitle("h12reweighted");
hSLreweighted->Reset();hSLreweighted->SetTitle("hSLreweighted");
auto h12dphiNSreweighted = (TH1F *)h12dphiNSall->Clone("h12dphiNSreweighted");
auto hSLdphiNSreweighted = (TH1F *)hSLdphiNSall->Clone("hSLdphiNSreweighted");
h12dphiNSreweighted->Reset();h12dphiNSreweighted->SetTitle("h12dphiNSreweighted");
hSLdphiNSreweighted->Reset();hSLdphiNSreweighted->SetTitle("hSLdphiNSreweighted");
auto h12dphireweighted = (TH1F *)h12dphiall->Clone("h12dphireweighted");
auto hSLdphireweighted = (TH1F *)hSLdphiall->Clone("hSLdphireweighted");
h12dphireweighted->Reset();h12dphireweighted->SetTitle("h12dphireweighted");
hSLdphireweighted->Reset();hSLdphireweighted->SetTitle("hSLdphireweighted");
auto h12ordreweighted = (TH1F *)h12ordall->Clone("h12ordreweighted");
auto hSLordreweighted = (TH1F *)hSLordall->Clone("hSLordreweighted");
h12ordreweighted->Reset();h12ordreweighted->SetTitle("h12ordreweighted");
hSLordreweighted->Reset();hSLordreweighted->SetTitle("hSLordreweighted");
h12reweighted->Add(h12fex,h12gsp,beta,gamma);
h12reweighted->Add(h12fcr);
hSLreweighted->Add(hSLfex,hSLgsp,beta,gamma);
hSLreweighted->Add(hSLfcr);
h12dphireweighted->Add(h12dphifex,h12dphigsp,beta,gamma);
h12dphireweighted->Add(h12dphifcr);
hSLdphireweighted->Add(hSLdphifex,hSLdphigsp,beta,gamma);
hSLdphireweighted->Add(hSLdphifcr);
h12dphiNSreweighted->Add(h12dphiNSfex,h12dphiNSgsp,beta,gamma);
h12dphiNSreweighted->Add(h12dphiNSfcr);
hSLdphiNSreweighted->Add(hSLdphiNSfex,hSLdphiNSgsp,beta,gamma);
hSLdphiNSreweighted->Add(hSLdphiNSfcr);
h12ordreweighted->Add(h12ordfex,h12ordgsp,beta,gamma);
h12ordreweighted->Add(h12ordfcr);
hSLordreweighted->Add(hSLordfex,hSLordgsp,beta,gamma);
hSLordreweighted->Add(hSLordfcr);
Normalize({h12data,h12all,hSLdata,hSLall,
//.........这里部分代码省略.........
开发者ID:bjet2015,项目名称:sanitychecks,代码行数:101,代码来源:skiplightreweightdraw.C
示例9: checkclosure
//.........这里部分代码省略.........
auto fmcPb = config.getfile_djt("mcPbbfa");
Fill(fmcPb,{"pthat","weight","jtpt1","refpt1","bProdCode","jtptSL","refptSL","dphiSL1","refparton_flavorForB1","subidSL","bin","pairCodeSL1","discr_csvV1_1","jteta1","jtetaSL"},[&] (dict d) {
if (d["pthat"]<pthatcut) return;
if (d["jtpt1"]>pt1cut && d["refpt1"]>50 && abs(d["refparton_flavorForB1"])==5 && d["jtptSL"]>pt2cut) {
int bin = getbinindex(d["bin"]);
float xj = d["jtptSL"]/d["jtpt1"];
float w = weight1SLPbPb(d);
if (AwaySide(d)) hasd[bin]->Fill(xj, w);
if (AwaySide(d) && IsSignal(d)) hsig[bin]->Fill(xj,w);
if (NearSide(d)) hbkg[bin]->Fill(xj,w);
if (NearSide(d) && !IsSignal(d)) hhyj[bin]->Fill(xj,w);
}
});
for (int i=0;i<Nbins;i++) {
hsub[i]->Add(hasd[i],hbkg[i],1,-1*bkgfractionInNearSide[i]);
hsbn[i]->Add(hasd[i],hbkg[i],1,-1);
hshj[i]->Add(hasd[i],hhyj[i],1,-1);
}
// for (int i=0;i<Nbins;i++)
// hincsub[i]->Add(hincasd[i],hincbkg[i],1,-1);
seth(bins);//Nbins,0,100);
auto hcentrSubSIG = geth("hcentrSubSIG","Signal;bin;#LTx_{J}#GT");
auto hcentrSubASD = geth("hcentrSubASD","Unsubtracted;bin;#LTx_{J}#GT");
auto hcentrSubBKS = geth("hcentrSubBKS","Subtracted w/o bkg scaling;bin;#LTx_{J}#GT");
auto hcentrSubCLS = geth("hcentrSubCLS","Subtracted with bkg scaling;bin;#LTx_{J}#GT");
auto hcentrSubHJS = geth("hcentrSubHJS","Subtracted Hydjet;bin;#LTx_{J}#GT");
plotlegendpos = BottomRight;
for (int i=0;i<Nbins;i++) {
hcentrSubSIG->SetBinContent(i+1,hsig[i]->GetMean());hcentrSubSIG->SetBinError(i+1,hsig[i]->GetMeanError());
hcentrSubASD->SetBinContent(i+1,hasd[i]->GetMean());hcentrSubASD->SetBinError(i+1,hasd[i]->GetMeanError());
hcentrSubBKS->SetBinContent(i+1,hsbn[i]->GetMean());hcentrSubBKS->SetBinError(i+1,hsbn[i]->GetMeanError());
hcentrSubCLS->SetBinContent(i+1,hsub[i]->GetMean());hcentrSubCLS->SetBinError(i+1,hsub[i]->GetMeanError());
hcentrSubHJS->SetBinContent(i+1,hshj[i]->GetMean());hcentrSubHJS->SetBinError(i+1,hshj[i]->GetMeanError());
Draw({hsig[i],hsub[i],hshj[i]});
}
plotymin = 0.55;//0.4;
plotymax = 0.7;//0.8;
plotlegendpos = BottomRight;
aktstring = "";
plotputmean = false;
//hcentrSubHJS - hydjet only subtraction
// SetMC({hcentrSubSIG, hcentrSubBKS, hcentrSubASD});
// SetData({hcentrSubCLS});
hcentrSubSIG->SetMarkerStyle(kOpenSquare);
hcentrSubBKS->SetMarkerStyle(kOpenSquare);
hcentrSubASD->SetMarkerStyle(kOpenSquare);
hcentrSubCLS->SetMarkerStyle(kFullCircle);
hcentrSubSIG->SetMarkerColor(TColor::GetColorDark(2)); hcentrSubSIG->SetLineColor(TColor::GetColorDark(2));
hcentrSubBKS->SetMarkerColor(TColor::GetColorDark(3)); hcentrSubBKS->SetLineColor(TColor::GetColorDark(3));
hcentrSubASD->SetMarkerColor(TColor::GetColorDark(4)); hcentrSubASD->SetLineColor(TColor::GetColorDark(4));
hcentrSubCLS->SetMarkerColor(TColor::GetColorDark(3)); hcentrSubCLS->SetLineColor(TColor::GetColorDark(3));
plotoverwritecolors = false;
plotlegenddx = -0.15;
Draw({hcentrSubSIG,hcentrSubASD, hcentrSubBKS, hcentrSubCLS});
auto syst = (TH1F *)hcentrSubSIG->Clone("syst");
syst->Add(hcentrSubCLS,-1);
map<TString,float> m;
for (unsigned i=0;i<bins.size()-1;i++) {
float misclosure = syst->GetBinContent(i+1);
float err = hcentrSubCLS->GetBinError(i+1);
m[Form("closure%d%d",(int)bins[i],(int)bins[i+1])]=sqrt(misclosure*misclosure+err*err);
}
WriteToFile(plotfoldername+"/hydjetclosuresyst.root",m);
}
开发者ID:bjet2015,项目名称:dibjets,代码行数:101,代码来源:hydjetclosure.C
示例10: _L8
pProperties->SetPropertyL(_L8("PropertyName4"), _L8("PropertyValue4"),
MSenLayeredProperties::ESenProviderSessionLayer);
pProperties->SetPropertyL(_L8("PropertyName5"), _L8("PropertyValue5"),
MSenLayeredProperties::ESenConsumerSessionLayer);
pProperties->SetPropertyL(_L8("PropertyName6"), _L8("PropertyValue6"),
MSenLayeredProperties::ESenMessageLayer);
TPtrC8 propertyValue;
pProperties->PropertyL(_L8("PropertyName1"), propertyValue);
pAsXml = pProperties->AsUtf8LC();
LOCAL_ASSERT( *pAsXml == KOutputString );
CleanupStack::PopAndDestroy(pAsXml);
TInt error;
pProperties2 = (CSenLayeredHttpTransportProperties*)pProperties->Clone(error);
LOCAL_ASSERT( error == KErrNone );
// Destroy cloned properties immediately after cloning
CleanupStack::PopAndDestroy(pProperties);
CleanupStack::PushL(pProperties2);
pAsXml = pProperties2->AsUtf8LC();
LOCAL_ASSERT( *pAsXml == KOutputString );
CleanupStack::PopAndDestroy(pAsXml);
CleanupStack::PopAndDestroy(pProperties2);
CleanupStack::PopAndDestroy(&stringPool);
return KErrNone;
}
开发者ID:gvsurenderreddy,项目名称:symbiandump-mw4,代码行数:31,代码来源:SenLayeredPropertiesTesterBlocks.cpp
示例11:
Local<Value> UnbindOperation::CreateCompletionArg()
{
auto a = statement->UnbindParams();
auto ret = a->Clone();
return ret;
}
开发者ID:TimelordUK,项目名称:node-sqlserver-v8,代码行数:6,代码来源:UnbindOperation.cpp
示例12: plotUnfoldingMatrixRooUnfold
//.........这里部分代码省略.........
TString subdir="ShapeReweight";
TString field="zeeMCShapeReweight_";
TString ddBkg=(inpMgr.userKeyValueAsInt("DDBKG")==1) ? "ddBkg" : "mcBkg";
field.Append(ddBkg);
std::cout << "Obtaining shape weights from <"
<< shapeFName << ">"
<< "(use" << ddBkg << ")\n";
h2ShapeWeights=LoadHisto2D(field,shapeFName,subdir,1);
if (!h2ShapeWeights) {
std::cout << "failed to find histo \"ZeeMCShapeReweight\"\n";
return retCodeError;
}
if ((DYTools::massBinningSet==DYTools::_MassBins_2012) &&
(DYTools::study2D==1)) {
HERE("set weights for the underflow bin to 1.");
int ibin=1;
for (int jbin=1; jbin<=24; jbin++) {
h2ShapeWeights->SetBinContent(ibin,jbin, 1.);
h2ShapeWeights->SetBinError (ibin,jbin, 0.);
}
}
std::cout << "shapeWeights:\n"; printHisto(h2ShapeWeights);
int ensembleSize= inpMgr.userKeyValueAsInt("RESIDUAL_STUDY_SIZE");
if (ensembleSize<=0) ensembleSize=100;
ensembleSize++;
std::cout << "EScale_residual ensemble size=" << ensembleSize
<< " (one added for non-randomized entry)\n";
std::vector<TString> tmpLabelV; // local variable for testing
specTH2DWeightV.reserve(ensembleSize);
tmpLabelV.reserve(ensembleSize);
specTH2DWeightV.push_back(Clone(h2ShapeWeights,
"h2NonRndShapeW","h2NonRndShapeW"));
tmpLabelV.push_back("NonRndShape");
if (!escaleResidual_global) {
TH2D *h2ResApply=Clone(h2ShapeWeights,"h2ResApply");
// vary randomly and independently in each bin
// prepare histo for randomization. Assume 10% error on the deviation
for (int ibin=1; ibin<=h2ResApply->GetNbinsX(); ++ibin) {
for (int jbin=1; jbin<=h2ResApply->GetNbinsY(); ++jbin) {
double dev=h2ResApply->GetBinContent(ibin,jbin);
//h2ResApply->SetBinError(ibin,jbin, 0.1*dev);
h2ResApply->SetBinError(ibin,jbin, 1.);
h2ResApply->SetBinError(ibin,jbin, dev);
}
}
HistoPair2D_t hpRnd("hpRnd",h2ResApply);
for (int i=1; i<ensembleSize; ++i) {
TString name=Form("rndShapeWeight_%d",i);
TH2D* h2Rnd=hpRnd.randomizedWithinErr(0,name);
specTH2DWeightV.push_back(h2Rnd);
tmpLabelV.push_back(name);
}
}
else { // global variation
for (int i=1; i<ensembleSize; ++i) {
double rnd=gRandom->Gaus(0,1.);
TString name=Form("rndShapeWeight_%d",i);
TH2D *h2Rnd=Clone(h2ShapeWeights,name);
for (int ibin=1; ibin<=h2Rnd->GetNbinsX(); ++ibin) {
for (int jbin=1; jbin<=h2Rnd->GetNbinsY(); ++jbin) {
开发者ID:andjuo,项目名称:DYee,代码行数:67,代码来源:plotUnfoldingMatrixRooUnfold.C
示例13: ZeroMallocFast
// パケットヘッダをコピーする
PKT *ClonePacket(PKT *p, bool copy_data)
{
PKT *ret;
// 引数チェック
if (p == NULL)
{
return NULL;
}
ret = ZeroMallocFast(sizeof(PKT));
ret->PacketSize = p->PacketSize;
// MAC ヘッダのコピー
ret->MacHeader = MallocFast(sizeof(MAC_HEADER));
Copy(ret->MacHeader, p->MacHeader, sizeof(MAC_HEADER));
// MAC フラグのコピー
ret->BroadcastPacket = p->BroadcastPacket;
ret->InvalidSourcePacket = p->InvalidSourcePacket;
// IPv6 関係構造体のコピー
Copy(&ret->IPv6HeaderPacketInfo, &p->IPv6HeaderPacketInfo, sizeof(IPV6_HEADER_PACKET_INFO));
Copy(&ret->ICMPv6HeaderPacketInfo, &p->ICMPv6HeaderPacketInfo, sizeof(ICMPV6_HEADER_INFO));
// Layer 3
ret->TypeL3 = p->TypeL3;
switch (ret->TypeL3)
{
case L3_ARPV4:
// ARP パケット
ret->L3.ARPv4Header = MallocFast(sizeof(ARPV4_HEADER));
Copy(ret->L3.ARPv4Header, p->L3.ARPv4Header, sizeof(ARPV4_HEADER));
break;
case L3_IPV4:
// IPv4 パケット
ret->L3.IPv4Header = MallocFast(sizeof(IPV4_HEADER));
Copy(ret->L3.IPv4Header, p->L3.IPv4Header, sizeof(IPV4_HEADER));
break;
case L3_IPV6:
// IPv6 パケット
ret->L3.IPv6Header = MallocFast(sizeof(IPV6_HEADER));
Copy(ret->L3.IPv6Header, p->L3.IPv6Header, sizeof(IPV6_HEADER));
ret->IPv6HeaderPacketInfo.IPv6Header = Clone(p->IPv6HeaderPacketInfo.IPv6Header,
sizeof(IPV6_HEADER));
ret->IPv6HeaderPacketInfo.HopHeader = Clone(p->IPv6HeaderPacketInfo.HopHeader,
sizeof(IPV6_OPTION_HEADER));
ret->IPv6HeaderPacketInfo.EndPointHeader = Clone(p->IPv6HeaderPacketInfo.EndPointHeader,
sizeof(IPV6_OPTION_HEADER));
ret->IPv6HeaderPacketInfo.RoutingHeader = Clone(p->IPv6HeaderPacketInfo.RoutingHeader,
sizeof(IPV6_OPTION_HEADER));
ret->IPv6HeaderPacketInfo.FragmentHeader = Clone(p->IPv6HeaderPacketInfo.FragmentHeader,
sizeof(IPV6_FRAGMENT_HEADER));
ret->IPv6HeaderPacketInfo.Payload = Clone(p->IPv6HeaderPacketInfo.Payload,
p->IPv6HeaderPacketInfo.PayloadSize);
break;
}
// Layer 4
ret->TypeL4 = p->TypeL4;
switch (ret->TypeL4)
{
case L4_ICMPV4:
// ICMPv4 パケット
ret->L4.ICMPHeader = MallocFast(sizeof(ICMP_HEADER));
Copy(ret->L4.ICMPHeader, p->L4.ICMPHeader, sizeof(ICMP_HEADER));
break;
case L4_ICMPV6:
// ICMPv6 パケット
ret->L4.ICMPHeader = MallocFast(sizeof(ICMP_HEADER));
Copy(ret->L4.ICMPHeader, p->L4.ICMPHeader, sizeof(ICMP_HEADER));
ret->ICMPv6HeaderPacketInfo.Data = Clone(p->ICMPv6HeaderPacketInfo.Data,
p->ICMPv6HeaderPacketInfo.DataSize);
ret->ICMPv6HeaderPacketInfo.EchoData = Clone(p->ICMPv6HeaderPacketInfo.EchoData,
p->ICMPv6HeaderPacketInfo.EchoDataSize);
switch (ret->ICMPv6HeaderPacketInfo.Type)
{
case ICMPV6_TYPE_ECHO_REQUEST:
case ICMPV6_TYPE_ECHO_RESPONSE:
break;
case ICMPV6_TYPE_ROUTER_SOLICIATION:
ret->ICMPv6HeaderPacketInfo.Headers.RouterSoliciationHeader =
Clone(p->ICMPv6HeaderPacketInfo.Headers.RouterSoliciationHeader,
sizeof(ICMPV6_ROUTER_SOLICIATION_HEADER));
break;
case ICMPV6_TYPE_ROUTER_ADVERTISEMENT:
//.........这里部分代码省略.........
开发者ID:falcon8823,项目名称:utvpn,代码行数:101,代码来源:TcpIp.c
示例14: ZeroMalloc
// Parse the SSTP packet
SSTP_PACKET *SstpParsePacket(UCHAR *data, UINT size)
{
SSTP_PACKET *p;
USHORT len;
// Validate arguments
if (data == NULL || size == 0)
{
return NULL;
}
if (size < 4)
{
return NULL;
}
p = ZeroMalloc(sizeof(SSTP_PACKET));
// Version
p->Version = *((UCHAR *)data);
data++;
size--;
if (p->Version != SSTP_VERSION_1)
{
// Invalid version
SstpFreePacket(p);
return NULL;
}
// Flag
if ((*((UCHAR *)data)) & 0x01)
{
p->IsControl = true;
}
data++;
size--;
// Length
len = READ_USHORT(data) & 0xFFF;
data += sizeof(USHORT);
size -= sizeof(USHORT);
if (len < 4)
{
// Invalid size
SstpFreePacket(p);
return NULL;
}
if (((UINT)(len - 4)) > size)
{
// Oversized
SstpFreePacket(p);
return NULL;
}
// Data
p->DataSize = len - 4;
p->Data = Clone(data, p->DataSize);
if (p->IsControl)
{
// Parse the Attribute list
p->AttibuteList = SstpParseAttributeList(p->Data, p->DataSize, p);
if (p->AttibuteList == NULL)
{
// Failure of parsing list
SstpFreePacket(p);
return NULL;
}
}
return p;
}
开发者ID:DreamLiMu,项目名称:SoftEtherVPN,代码行数:76,代码来源:Interop_SSTP.c
示例15: DASSERT
//==================================================================
void SimplePrimitiveBase::Split( Hider &hider, bool uSplit, bool vSplit )
{
DASSERT( IsUsed() );
if ( mSplitCnt > 9 )
{
// $$$ too many splits !!!
(void)mSplitCnt;
return;
}
if ( uSplit )
{
// U split
SimplePrimitiveBase *pPrimsSU[2] =
{
Clone(),
Clone()
};
float uMid = (mURange[0] + mURange[1]) * 0.5f;
pPrimsSU[0]->mURange[1] = uMid;
pPrimsSU[1]->mURange[0] = uMid;
hider.InsertSplitted( pPrimsSU[0], *this );
hider.InsertSplitted( pPrimsSU[1], *this );
if ( vSplit )
{
// optional V split
float vMid = (mVRange[0] + mVRange[1]) * 0.5f;
// check.. because we can't be sure that the primitive didn't fail
// at insertion time
for (size_t i=0; i < 2; ++i)
{
if ( pPrimsSU[i]->IsUsed() )
{
SimplePrimitiveBase *pNewPrim = pPrimsSU[i]->Clone();
pPrimsSU[i]->mVRange[1] = vMid;
pNewPrim->mVRange[0] = vMid;
hider.InsertSplitted( pNewPrim, *pPrimsSU[i] );
}
}
}
}
else
{
// exclusive V split
if ( vSplit )
{
SimplePrimitiveBase *pPrim1 = Clone();
SimplePrimitiveBase *pPrim2 = Clone();
float vMid = (mVRange[0] + mVRange[1]) * 0.5f;
pPrim1->mVRange[1] = vMid;
pPrim2->mVRange[0] = vMid;
hider.InsertSplitted( pPrim1, *this );
hider.InsertSplitted( pPrim2, *this );
}
}
}
开发者ID:UIKit0,项目名称:RibTools,代码行数:62,代码来源:RI_Primitive_Base.cpp
示例16: CPDF_Reference
CPDF_Object* CPDF_Object::CloneRef(CPDF_IndirectObjectHolder* pDoc) const {
if (m_ObjNum) {
return new CPDF_Reference(pDoc, m_ObjNum);
}
return Clone();
}
开发者ID:primiano,项目名称:pdfium-merge,代码行数:6,代码来源:fpdf_parser_objects.cpp
示例17: CloseDownClient
void
CloseDownClient(ClientRec *client)
{
int index_deleted = 0;
if (verbose) {
printf ("ICE Connection closed, IceConn fd = %d\n",
IceConnectionNumber (client->ice_conn));
printf ("\n");
}
SmsCleanUp (client->smsConn);
IceSetShutdownNegotiation (client->ice_conn, False);
IceCloseConnection (client->ice_conn);
client->ice_conn = NULL;
client->smsConn = NULL;
if (!shutdownInProgress && client_info_visible)
{
for (index_deleted = 0;
index_deleted < numClientListNames; index_deleted++)
{
if (clientListRecs[index_deleted] == client)
break;
}
}
ListSearchAndFreeOne (RunningList, (char *) client);
if (saveInProgress)
{
Status delStatus = ListSearchAndFreeOne (
WaitForSaveDoneList, (char *) client);
if (delStatus)
{
ListAddLast (FailedSaveList, (char *) client);
client->freeAfterBadSavePopup = True;
}
ListSearchAndFreeOne (WaitForInteractList, (char *) client);
ListSearchAndFreeOne (WaitForPhase2List, (char *) client);
if (delStatus && ListCount (WaitForSaveDoneList) == 0)
{
if (ListCount (FailedSaveList) > 0 && !checkpoint_from_signal)
PopupBadSave ();
else
FinishUpSave ();
}
else if (ListCount (WaitForInteractList) > 0 &&
OkToEnterInteractPhase ())
{
LetClientInteract (ListFirst (WaitForInteractList));
}
else if (!phase2InProgress &&
ListCount (WaitForPhase2List) > 0 && OkToEnterPhase2 ())
{
StartPhase2 ();
}
}
if (client->restartHint == SmRestartImmediately && !shutdownInProgress)
{
Clone (client, True /* use saved state */);
ListAddLast (RestartImmedList, (char *) client);
}
else if (client->restartHint == SmRestartAnyway)
{
ListAddLast (RestartAnywayList, (char *) client);
}
else if (!client->freeAfterBadSavePopup)
{
FreeClient (client, True /* free props */);
}
if (shutdownInProgress)
{
if (ListCount (RunningList) == 0)
EndSession (0);
}
else if (client_info_visible)
{
UpdateClientList ();
if (current_client_selected == index_deleted)
{
if (current_client_selected == numClientListNames)
current_client_selected--;
if (current_client_selected >= 0)
{
XawListHighlight (clientListWidget, current_client_selected);
ShowHint (clientListRecs[current_client_selected]);
if (client_prop_visible)
{
DisplayProps (clientListRecs[current_client_selected]);
}
//.........这里部分代码省略.........
开发者ID:aosm,项目名称:X11,代码行数:101,代码来源:xsm.c
示例18: return
UIStaticText *UIStaticText::CloneStaticText()
{
return (UIStaticText *)Clone();
}
开发者ID:dima-belsky,项目名称:dava.framework,代码行数:4,代码来源:UIStaticText.cpp
示例19: return
PolyMesh* PolyMesh::ToPolyMesh()
{
return (PolyMesh*)Clone();
}
开发者ID:Neoniet,项目名称:upspring,代码行数:4,代码来源:PolyMesh.cpp
示例20: clone
void clone( const TrafficIPC::Disturbances& cloneThese,
TrafficIPC::Disturbances& toMe ) {
std::transform( cloneThese.begin(), cloneThese.end(),
std::back_inserter( toMe ), Clone() );
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:5,代码来源:TrafficHandlerTest.cpp
注:本文中的Clone函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论