Esempio n. 1
0
	// get or create the record for a specified key
	void *Untyped::Open(Key aKey)
	{
		// convert key to a slot
		// (HACK: assume key is already a hash)
		size_t slot = FindSlot(aKey);

		// if the slot is not empty...
		if (slot != EMPTY)
		{
			// return the record
			return GetRecord(slot);
		}

		// grow if the database is full
		if (mCount >= mLimit)
			Grow();

		// add a new record
		void *record = AllocRecord(aKey);

		// check parent
		const void *source = mNil;
		if (this != &parent && parent.GetCount())
			if (Key aParentKey = parent.Get(aKey))
				source = Find(aParentKey);
		CreateRecord(record, source);

		// return the record
		return record;
	}
Esempio n. 2
0
void  HandleServNew(stRcvdMsg * pstRcvdMsg ,int8 * pi8MsgPtr,uint64 ui64ID)
{
 int8 * pi8SavePtr = NULL;
 int8 * pi8Token = NULL;
 uint64 ui64RecId = 0;
 stRecord * pstRedAdd = NULL;

 if(NULL != pi8MsgPtr)
 { 
    pi8Token = strtok_r(pi8MsgPtr , DELIMITER , &pi8SavePtr);
    if(0 == strcmp("CLIENTID",pi8Token))
    {
        pi8Token = strtok_r(NULL , DELIMITER , &pi8SavePtr);
        ui64RecId = strtol(pi8Token,NULL,0);
        if(NULL == (pstRedAdd = SearchRecord(ui64RecId)))
       {
           /*New record should be created for a new client*/
           pstRedAdd = CreateRecord(ui64RecId);
           if(NULL != pstRedAdd)
           {
               pstRedAdd->ui64RecNum = ui64RecId;
               FillRecord(pstRedAdd,pi8SavePtr);
               pstRedAdd->ui32ContentFull = 0;
           }	           
      }
      else
      {
           /*Client already exists,just update*/      
           FillRecord(pstRedAdd,pi8SavePtr); 
      }
    }
    freeMsg(pstRcvdMsg);
 }
}
static void OnRecordBeg(HWND hwnd, LPARAM lParam)
{
	if (!my_voiceprint.myRecord && !my_voiceprint.g_RecThreadID)
	{
		my_voiceprint.myRecord = CreateRecord(hwnd);
		SetWindowText(GetDlgItem(hwnd, lParam), TEXT("停止"));
		SetWindowLong(GetDlgItem(hwnd, lParam), GWL_ID, IDC_VOICE_STOP);
	}
}
Esempio n. 4
0
	// copy a source database
	void Untyped::Copy(const Untyped &aSource)
	{
		// free existing arrays
		Free();

		// release pool
		if (mPool)
		{
			mPool->Release();
		}

		// use the source pool
		mPool = aSource.mPool;
		mPool->AddRef();

		// copy counts
		mBits = aSource.mBits;
		mMask = aSource.mMask;
		mLimit = aSource.mLimit;
		mCount = aSource.mCount;

		// create new arrays
		Alloc();

		// copy map
		memcpy(mMap, aSource.mMap, mLimit * 2 * sizeof(size_t));

		// copy keys
		memcpy(mKey, aSource.mKey, mLimit * sizeof(size_t));
		memset(mKey + mCount, 0, (mLimit - mCount) * sizeof(size_t));

		// copy data
		for (size_t slot = 0; slot < mCount; ++slot)
		{
			mData[slot] = mPool->Alloc();
			CreateRecord(GetRecord(slot), aSource.GetRecord(slot));
		}
		memset(mData + mCount, 0, (mLimit - mCount) * sizeof(void *));

		// copy default
		CreateRecord(mNil, aSource.mNil);
	}
Esempio n. 5
0
/*---------------------------------------------------------------------------------*/
 void CollateFileUsingScheme ( CCB_Header * h )
/*---------------------------------------------------------------------------------*/
   {
      CCB_CollateFile * c;
      FCB_File * f;

      c = ( CCB_CollateFile * ) h;

      if ( f = SfsOpenFile ( c -> FileExtrinsicKey ) )
        {
           if ( c -> RecordSize )
             RecordSize = c -> RecordSize;
           else
             if ( f -> RecordSize )
               RecordSize = f -> RecordSize;
             else
               RecordSize = K;

           if ( RecordSize > OneFrameSize )
             NotifyAndActAsProper ( ErrorImproperRecordSpan );

           Count = c -> Count;

           SetCollateFileBoundaries ( f );

           PatternIndex = c -> PatternIndex;
           CreateRecords ( PatternIndex, RecordSize );

           if ( Records )
             while ( Count -- )
               {
                  GetReadyForNextFileRecord ( f );
                  SfsReadFile ( f );
                  CreateRecord ( NewRecord + 1 );
                  CollateRecords ();
               }
           else
             NotifyAndActAsProper ( ErrorNothingToCollate );

           CloseFile ( f );
        }
      return;
   }
Esempio n. 6
0
void AssignIDToCli(stRcvdMsg * pstRcvdMsg)
{

  static uint64 ui64ClientID = 1;
  uint32 ui32BitMask = 0;
  stRecord * pstRedAdd = NULL;

  /*Check for the range applicable to client, and assign an ID*/

  if((ui64ClientID > gi64StartID)  && (ui64ClientID < gi64EndID))
  {
     pstRedAdd = CreateRecord(gi64ServID+ui64ClientID);
     ui32BitMask += CLIENT|CLIENTID;
     PrepareCliRsp(pstRcvdMsg,pstRedAdd,ui32BitMask);
     ui64ClientID++;
  }

 

}
Esempio n. 7
0
	// create or update a record for a specified key
	void Untyped::Put(Key aKey, const void *aValue)
	{
		// convert key to a slot
		// (HACK: assume key is already a hash)
		size_t slot = FindSlot(aKey);

		// if the slot is not empty...
		if (slot != EMPTY)
		{
			// update the record
			UpdateRecord(GetRecord(slot), aValue);
			return;
		}

		// grow if the database is full
		if (mCount >= mLimit)
			Grow();

		// add a new record
		void *record = AllocRecord(aKey);
		CreateRecord(record, aValue);
	}