Esempio n. 1
0
File: ISmb.cpp Progetto: FEI17N/Lgi
	bool Read()
	{
		Conn->Read((char*) Protocol, sizeof(Protocol), 0);
		Command = ReadUShort();
		Status.Status = ReadULong();
		Flags = ReadUChar();
		Flags2 = ReadUShort();
		Conn->Read((char*) Pad, sizeof(Pad), 0);
		Tid = ReadUShort();
		Pid = ReadUShort();
		Uid = ReadUShort();
		Mid = ReadUShort();
		
		WordCount = ReadUChar();
		DeleteArray(ParameterWords);
		ParameterWords = new ushort[WordCount];
		if (ParameterWords)
		{
			Conn->Read((char*) ParameterWords, sizeof(ushort)*WordCount, 0);
		}

		ByteCount = ReadUChar();
		DeleteArray(Buffer);
		Buffer = new uchar[ByteCount];
		if (Buffer)
		{
			Conn->Read((char*) Buffer, sizeof(uchar)*ByteCount, 0);
		}

		return true;
	}
int OS::StackWalk(Vector<OS::StackFrame> frames) {
  int frames_size = frames.length();
  void** addresses = NewArray<void*>(frames_size);

  int frames_count = backtrace(addresses, frames_size);

  char** symbols;
  symbols = backtrace_symbols(addresses, frames_count);
  if (symbols == NULL) {
    DeleteArray(addresses);
    return kStackWalkError;
  }

  for (int i = 0; i < frames_count; i++) {
    frames[i].address = addresses[i];
    // Format a text representation of the frame based on the information
    // available.
    SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen),
             "%s",
             symbols[i]);
    // Make sure line termination is in place.
    frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
  }

  DeleteArray(addresses);
  free(symbols);

  return frames_count;
}
Esempio n. 3
0
File: GRect.cpp Progetto: FEI17N/Lgi
bool GRegion::SetSize(int s)
{
	bool Status = true;

	if (s > Alloc)
	{
		int NewAlloc = (s + 15) & (~0xF);
		GRect *Temp = new GRect[NewAlloc];
		if (Temp)
		{
			int Common = min(Size, s);
			memcpy(Temp, a, sizeof(GRect)*Common);
			DeleteArray(a);
			a = Temp;
			Size = s;
			Alloc = NewAlloc;
		}
		else
		{
			Status = false;
		}
	}
	else
	{
		Size = s;
		if (!Size)
		{
			DeleteArray(a);
			Alloc = 0;
		}
	}

	return Status;
}
Esempio n. 4
0
CMotion::~CMotion()
{
	DeleteArray(m_attributes);
	DeleteArray(m_paths);
	DeleteArray(m_bones);
	DeleteArray(m_animations);
	DeleteArray(m_frames);
}
Esempio n. 5
0
ArcScriptCreatureAI::~ArcScriptCreatureAI()
{
	DeleteArray(mOnDiedEmotes);
	DeleteArray(mOnTargetDiedEmotes);
	DeleteArray(mOnCombatStartEmotes);
	DeleteArray(mOnTauntEmotes);
	DeleteArray(mSpells);
}
Esempio n. 6
0
/*
*****************************************************************************
**函 数 名:Uint8 GetCycle(Uint8 *p,Uint8 n)
**功能描述:算周期
**输    入:Uint8 *p,Uint8 n
**输    出:
*****************************************************************************
*/
Uint8 GetCycle(Uint8 *p,Uint8 n)                //算周期
{
	Uint8 xdata i,j,account,condition,tempMin,posMin,posMax;
	Uint16 xdata tempMax;
	Uint8 xdata cycle = 0;

	condition =(Uint16)(SerialMore(p,n)+SerialLess(p,n))*4/5;
	for(i=MIN_POINT;i<=MAX_POINT;i++)
	{
		CalculateArea(p,i);
		account=FindLeastValue(GatDat->Area,TOTAL-i);
		while(account>=3)
		{
			tempMin = 0xff;
			posMin = 0;
			for(j=0;j<(account-1);j++)
			{
				if(abs(GatDat->Num[j+1]-GatDat->Num[j])<tempMin)
				{
					tempMin = abs(GatDat->Num[j+1]-GatDat->Num[j]);
					posMin  = j;
				}
			}
			if(tempMin<condition)
			{
				if(GatDat->Area[GatDat->Num[posMin]] > GatDat->Area[GatDat->Num[posMin+1]])
					DeleteArray(account,posMin);
				else
					DeleteArray(account,posMin+1);
				account --;
			}
			else
			{
				cycle=DistanceEqu(account);
				if(cycle)
					return cycle;
				else
				{
					tempMax = 0;
					posMax = 0xff;
					for(j=0;j<account;j++)
					{
						if(GatDat->Area[GatDat->Num[j]]>=tempMax)
						{
							tempMax = GatDat->Area[GatDat->Num[j]];
							posMax  = j;
						}
					}
					DeleteArray(account,posMax);
					account --;
				}
			}
		}
	}
	return 0;
}
Esempio n. 7
0
CProject::~CProject()
{
	Project = null;

	for (int i = 0; i < m_waterListCount; i++)
	{
		DeleteArray(m_waterLists[i].textures);
		DeleteArray(m_waterLists[i].textureIDs);
	}
	DeleteArray(m_waterLists);
}
Esempio n. 8
0
void ArcScriptCreatureAI::RemoveAllEmotes(EventType pEventType)
{
	switch( pEventType )
	{
		case Event_OnCombatStart:	DeleteArray(mOnCombatStartEmotes); break;
		case Event_OnTargetDied:	DeleteArray(mOnTargetDiedEmotes); break;
		case Event_OnDied:			DeleteArray(mOnDiedEmotes); break;
		case Event_OnTaunt:			DeleteArray(mOnTauntEmotes); break;
		default:					sLog.outDebug("ArcScriptCreatureAI::RemoveAllEmotes() : Invalid event type!\n"); break;
	}
}
Esempio n. 9
0
File: GText.cpp Progetto: FEI17N/Lgi
TextLock::~TextLock()
{
	DeleteArray(Line);
	if (LineW)
	{
		for (int i=0; i<Lines; i++)
		{
			DeleteArray(LineW[i]);
		}
		DeleteArray(LineW);
	}
}
Esempio n. 10
0
HRESULT AllocMeshHierarchy::DestroyFrame( THIS_ D3DXFRAME* pFrameToFree)
{
	DeleteArray(pFrameToFree->Name) ;
	Delete(pFrameToFree) ;

	return D3D_OK ;
}
Esempio n. 11
0
bool GCombo::Insert(char *p, int Index)
{
	bool Status = false;

	if (p)
	{
		if (Handle())
		{
			char *n = LgiToNativeCp(p);
			if (n)
			{
				if (Index < 0)
				{
					Index = GetItems();
				}

				Status = SendMessage(Handle(), CB_INSERTSTRING, Index, (long)n) == Index;
				DeleteArray(n);
			}
		}
		else
		{
			d->InitStrs.Insert(NewStr(p), Index);
			Status = true;
		}
	}

	return Status;
}
Esempio n. 12
0
File: GText.cpp Progetto: FEI17N/Lgi
bool TextDocument::SetLength(int Len)
{
	bool Status = TRUE;

	if (Len + 1 > Alloc)
	{
		int NewAlloc = (Len + TEXT_BLOCK) & (~TEXT_MASK);
		char *Temp = new char[NewAlloc];
		if (Temp)
		{
			memset(Temp + Length, 0, NewAlloc - Length);
			memcpy(Temp, Data, Length);
			DeleteArray(Data);
			Data = Temp;
			Length = Len;
			Alloc = NewAlloc;
		}
		else
		{
			Status = FALSE;
		}
	}
	else
	{
		// TODO: resize Data to be smaller if theres a
		// considerable size change
		Length = Len;
	}

	return Status;
}
Esempio n. 13
0
void PrettyPrinter::Print(const char* format, ...) {
  for (;;) {
    va_list arguments;
    va_start(arguments, format);
    int n = OS::VSNPrintF(Vector<char>(output_, size_) + pos_,
                          format,
                          arguments);
    va_end(arguments);

    if (n >= 0) {
      // there was enough space - we are done
      pos_ += n;
      return;
    } else {
      // there was not enough space - allocate more and try again
      const int slack = 32;
      int new_size = size_ + (size_ >> 1) + slack;
      char* new_output = NewArray<char>(new_size);
      OS::MemCopy(new_output, output_, pos_);
      DeleteArray(output_);
      output_ = new_output;
      size_ = new_size;
    }
  }
}
Esempio n. 14
0
void Test(int row, int col, int bomb, int &y, int &x)
{
	struct pole** src;
	src = CreateArray(row, col);
	if (src == NULL)
		cout << "Problem\n";
	Random(src, row, col, bomb);
		//	bool wygrana = IsWin(src, row, col, bomb);
	bool bomba = false;
	int zakryte = row*col; // zakryte pola
	while (zakryte != bomb) {
		Write(src, row, col, y, x);
		//CountFlags(src, row, col, bomb);
		//ShowCell(src, row, col, y, x);
		PressKey(src, row, col, bomb, y, x,zakryte);
		bomba = IfBomb(src, row, col, y, x);
		if (bomba == true) break;
		system("cls");
    }
	x = 0;
	y = 0;
	if (zakryte == bomb) { //warunek wygranej
		cout << "Gratulacje, wygrales!\n\n";
	}
	Write(src, row, col, y, x);
	cout << "\n";
	DeleteArray(&src, row);
}
Esempio n. 15
0
GenerateSequence::GenerateRandom(int Size)
{
    if(Value != NULL) DeleteArray();
    Value = new int[Size];
    for(int i=0;i<Size;i++) Value[i]=RandomNumber();
    return 0;
}
Esempio n. 16
0
byte *LoadFile(TCHAR const *filename, size_t *size)
{
	byte *buf = null;
	File f(filename, File::AccessRead);
	if(f.IsValid())
	{
		size_t fsize = f.Size();
		buf = new byte[fsize + sizeof(WCHAR)];
		if(buf != null)
		{
			size_t s = f.Read(buf, fsize);
			if(s != fsize)
			{
				DeleteArray(buf);
			}
			else
			{
				*((WCHAR *)(((char *)buf) + fsize)) = L'\0';
				if(size != null)
				{
					*size = fsize;
				}
			}
		}
	}
	return buf;
}
Esempio n. 17
0
void CWndControl::SetTexture(const string& filename, bool tiles)
{
    m_textureName = filename;
    m_tiles = tiles;
    m_hasTexture = false;
    m_texture = null;
    DeleteArray(m_textureTiles);

    if (m_textureName.isEmpty())
        return;

    if (m_tiles && GetTilesCount() > 0)
    {
        m_textureTiles = new CTexture*[GetTilesCount()];
        memset(m_textureTiles, 0, sizeof(CTexture*) * GetTilesCount());

        string temp;
        const string name = m_textureName.left(m_textureName.size() - 6);
        const string ext = m_textureName.right(4);
        for (int i = 0; i < GetTilesCount(); i++)
        {
            temp = name % string().sprintf("%02d", i) % ext;
            m_textureTiles[i] = TextureMng->GetGUITexture(temp);

            if (m_textureTiles[i])
                m_hasTexture = true;
        }
    }
    else
    {
        m_texture = TextureMng->GetGUITexture(m_textureName);
        if (m_texture)
            m_hasTexture = true;
    }
}
Esempio n. 18
0
//-----------------------------------------------------------------------------
EStatus BaseArray::SetLength (INT  iLengthIn)
  {
  INT    iNewAllocSize = iAllocSize;

  // calculate how much to grow the array.
  while (iLengthIn > iNewAllocSize)
    {
    iNewAllocSize += iAllocInc;
    };

  // if more memory is to be allocated, allocate it, copy over old values, and delete old memory.
  if (iNewAllocSize > iAllocSize)
    {
    VOID *  pNewArray = AllocArray (iNewAllocSize);

    // Note:  Ideally you need to detect an allocation failure here and return a failure code.
    if (pNewArray == NULL)  return (EStatus::kFailure);

    INT     iOldAllocSize = iAllocSize;
    VOID *  pOldArray     = pArray;

    pArray = pNewArray;
    iAllocSize = iNewAllocSize;

    if (iOldAllocSize > 0)
      {
      CopyValues (pOldArray, 0, 0, iOldAllocSize);
      DeleteArray (&pOldArray);
      };
    };
  iLength = iLengthIn;
  return (EStatus::kSuccess);
  };
Esempio n. 19
0
GenerateSequence::GenerateDecreasing(int Size)
{
    if(Value != NULL) DeleteArray();
    Value = new int[Size];
    for(int i=0;i<Size;i++) Value[i]=Size-i;
    return 0;
}
Esempio n. 20
0
void calc_interpolated_prob(arpa_lm_t *lm, arpa_lm_t *lm1, arpa_lm_t *lm2,fb_info* fb1,fb_info* fb2,double w1,double w2)
{
	TBROWSE br;
	id__t id[MAX_K];
	char** words;
	int k,j;
	double p1,p2,p;

	words=(char**)NewArray(MAX_K,MAX_WORD,sizeof(char));

	for (k=1;k<=lm->n;k++) {
		begin_browse(lm,k,&br);
		j=0;
		printf("\nProcessing %d-gram\n",k);
		while (get_next_ngram(id,&br)) {
		  j++;
		  show_dot(j);
			ids2words(words,id,k,lm->vocab);
			p1=calc_prob(words,k,lm1,fb1);
			p2=calc_prob(words,k,lm2,fb2);
			p=w1*p1+w2*p2;
			lm->probs[k-1][br.pos[k-1]-1]=log10(p);
			/* comment out this probability correction
			if(lm->probs[k-1][br.pos[k-1]-1]==0.0){
				lm->probs[k-1][br.pos[k-1]-1]=-0.00001;
			}
			*/

		}
	}

	DeleteArray(words);
}
Esempio n. 21
0
ImmediateContext::~ImmediateContext()
{
	for(uint i=0; i<kNumBuffers; ++i)
	{
		::Release(mVertexBuffer[i]);
		::Release(mConstantBuffer[i]);
	}
	DeleteArray(mCommandBuffer);
}
Esempio n. 22
0
/**
   Very similar to write_lms except that it use arpa_lm_t but not
   lm_t.  Headers of the two files are also written. 
 */
void write_interpolated_lm(arpa_lm_t *ng, const char* arpa_filename, const char* header1, const char* header2, int verbosity) 
{		
  int i;
  int j;
  FILE* fp;
  TBROWSE br;
  id__t id[MAX_K];
  char** words;
  
  words=(char**)NewArray(MAX_K,MAX_WORD,sizeof(char));
  if (words==NULL) {
    Error ("Cannot allocate memory");
    return;
  }
  
  if ((fp=fopen(arpa_filename,"w"))==NULL) {
    Error ("Cannot open file to write arpa lm file.");
    return ;
  }
	
  /* HEADER */
  
  pc_message(verbosity,1,"ARPA-style %d-gram will be written to %s\n",ng->n,arpa_filename);
  
  write_arpa_copyright(fp,ng->n,(int) ng->vocab_size,ng->vocab[1],ng->vocab[2],ng->vocab[3]);
  write_arpa_format(fp,ng->n);	
  write_arpa_headers(fp, header1, header2);
  write_arpa_num_grams(fp,NULL,ng,1);
 
  /* Print 1-gram, ... n-gram info. */
  
  for (i=0;i<=ng->n-1;i++) {    
    /* Print out the (i+1)-gram */		
    write_arpa_k_gram_header(fp,i+1);
    
    begin_browse(ng,i+1,&br);
    
    /* Go through the n-gram list in order */
    
    while (get_next_ngram(id,&br)) {
      fprintf(fp,"%.4f ",ng->probs[i][br.pos[i]-1]);
      for (j=0;j<=i;j++)
	fprintf(fp,"%s ",ng->vocab[id[j]]);

      if (i <= ng->n-2)
	fprintf(fp,"\t%.4f\n",ng->bo_weight[i][br.pos[i]-1]);
      else
	fprintf(fp,"\n");
    }
  }	
	
  fprintf(fp,"\n\\end\\\n");

  fclose(fp);
	
  DeleteArray(words);
} 
Esempio n. 23
0
HRESULT AllocMeshHierarchy::DestroyMeshContainer( THIS_ D3DXMESHCONTAINER* pMeshContainerBase)
{
	DeleteArray(pMeshContainerBase->Name) ;
	DeleteArray(pMeshContainerBase->pAdjacency) ;
	DeleteArray(pMeshContainerBase->pEffects) ;

	for ( DWORD i = 0 ; i < pMeshContainerBase->NumMaterials ; ++i )
		DeleteArray(pMeshContainerBase->pMaterials[i].pTextureFilename) ;

	DeleteArray(pMeshContainerBase->pMaterials) ;

	ReleaseCOM(pMeshContainerBase->MeshData.pMesh) ;
	ReleaseCOM(pMeshContainerBase->pSkinInfo) ;

	Delete(pMeshContainerBase) ;

	return D3D_OK ;
}
Esempio n. 24
0
GenerateSequence::GenerateAShaped(int Size)
{
    if(Value != NULL) DeleteArray();
    Value = new int[Size];
    for(int i=0;i<Size;i++)
    {
        if(i<=Size/2) Value[i]=i;
        else Value[i]=Value[Size/2]+(Size/2-i);
    }
    return 0;
}
Esempio n. 25
0
int main() {

    int m=10,n=100;
    char** a;
    a=CreateArray(n,m);
    RandomFill (a,n,m);
    PrintArray (a,n,m);
    DeleteArray(a,n);

    return 0;

}
Esempio n. 26
0
File: GText.cpp Progetto: FEI17N/Lgi
void TextView::SetStatus(char *Msg)
{
	if (Msg)
	{
		DeleteArray(StatusMsg);
		StatusMsg = new char[strlen(Msg)+1];
		if (StatusMsg)
		{
			strcpy(StatusMsg, Msg);
		}
	}
}
Esempio n. 27
0
void CDialogSkinAuto::LoadSkel()
{
	const string skel = QFileDialog::getOpenFileName(this, tr("Charger un squelette"),
		"Model/", tr("Fichier squelette (*.chr)"));

	if (!skel.isEmpty())
	{
		QFileInfo fileInfo(skel);
		ModelMng->SetModelPath(fileInfo.path() % '/');
		CSkeleton* skl = ModelMng->GetSkeleton(fileInfo.fileName());

		if (skl)
		{
			Delete(m_mesh->m_skeleton);
			m_mesh->m_skeleton = skl;
			DeleteArray(m_mesh->m_bones);
			ui.bonesList->clear();
			m_items.clear();

			ui.skelName->setText(fileInfo.fileName());

			m_mesh->m_bones = new D3DXMATRIX[skl->GetBoneCount() * 2];
			m_mesh->m_invBones = m_mesh->m_bones + skl->GetBoneCount();
			skl->ResetBones(m_mesh->m_bones, m_mesh->m_invBones);

			QList<QTreeWidgetItem*> items;

			QTreeWidgetItem* item;
			Bone* bone;
			for (int i = 0; i < skl->GetBoneCount(); i++)
			{
				bone = &skl->m_bones[i];
				item = new QTreeWidgetItem(QStringList(bone->name));
				item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
				item->setCheckState(0, Qt::Unchecked);
				item->setData(0, Qt::UserRole + 1, QVariant(i));
				m_items[i] = item;

				if (bone->parentID == -1)
					items.append(item);
				else
					m_items[bone->parentID]->addChild(item);
			}

			ui.bonesList->insertTopLevelItems(0, items);
			ui.bonesList->expandAll();

			ui.okSkel->setEnabled(true);
		}
	}
}
Esempio n. 28
0
File: GMenu.cpp Progetto: FEI17N/Lgi
GSubMenu::GSubMenu(const char *name, bool Popup)
{
	if (name)
	{
		char *Temp = NewStrLessAnd(name);
		if (Temp)
		{
			Info = new BMenu(Temp);
			DeleteArray(Temp);
		}
	}

	Parent = 0;
	Menu = 0;
	Window = 0;
}
Esempio n. 29
0
int RunCommand (struct data * d)
{
	int status = COMMAND_OK;
	struct comand * c;
	c = d->l->c;
	d->l->c = NULL;
	status = ProcessInternalCommand (d, c);
	if (c != NULL)
	{
		if (c->in != NULL)
			free (c->in);
		if (c->out != NULL)
			free (c->out);
		DeleteArray (c->argv);
		free (c);
	}
	return status;
}
Esempio n. 30
0
CWorld::~CWorld()
{
	int i, j;
	for (i = 0; i < m_continents.GetSize(); i++)
		Delete(m_continents[i]);
	for (i = 0; i < MAX_OBJTYPE; i++)
		for (j = 0; j < m_objects[i].GetSize(); j++)
			Delete(m_objects[i].GetAt(j));
	if (m_lands)
	{
		for (i = 0; i < m_width * m_height; i++)
			Delete(m_lands[i]);
		DeleteArray(m_lands);
	}
	for (auto it = m_paths.begin(); it != m_paths.end(); it++)
		Delete(it.value());
	Delete(m_skybox);
}