Exemple #1
0
	/**
	 * Initialize the static resource array.
	 * This function saves the old objects present
	 * in the array.
	 * @param numResources The number of resource in the new array.
	 */
	void ResourceArray::init(unsigned numResources) {
		unsigned oldResSize = mResSize;
		mResSize = MAX(numResources + 1, oldResSize);
		void** oldRes = mRes;
		byte* oldTypes = mResTypes;
		mRes = new void*[mResSize];
		MYASSERT(mRes != NULL, ERR_OOM);
		mResTypes = new byte[mResSize];
		MYASSERT(mResTypes != NULL, ERR_OOM);

		if(oldRes) {
			memcpy(mRes, oldRes, oldResSize*sizeof(void*));
			memcpy(mResTypes, oldTypes, oldResSize*sizeof(byte));
			delete[] oldRes;
			delete[] oldTypes;
		}

		if(mResSize > oldResSize) {
			// Clear the new objects.
			//pointer arithmetic bug
			//memset(mRes + oldResSize*sizeof(void*), 0, (mResSize - oldResSize)*sizeof(void*));
			memset(&mRes[oldResSize], 0, (mResSize - oldResSize) * sizeof(void*));
			// Set to placeholder type.
			memset(mResTypes + oldResSize, RT_PLACEHOLDER, (mResSize - oldResSize));
		}
	}
Statistics::Statistics(const QString& filename, const QString& separator) :
    m_stat_file(new QFile(filename)), m_separator(separator)
{
    MYASSERT(m_stat_file != 0);
    MYASSERT(m_stat_file->open(QIODevice::WriteOnly));
    MYASSERT(!m_separator.isEmpty());
}
FMCSound::FMCSound(const QString & filename, SOUND_SOURCE sound_source, FMOD_SYSTEM *fmod_system) :
    FMCSoundBase(sound_source), m_filename(filename), m_fmod_system(fmod_system), m_fmod_sound(0), m_fmod_channel(0)
{
    MYASSERT(!filename.isEmpty());
    MYASSERT(m_fmod_system != 0);
    MYASSERT(FMOD_System_CreateSound(m_fmod_system, filename.toLatin1().data(), FMOD_HARDWARE, 0, &m_fmod_sound) == FMOD_OK);
}
Exemple #4
0
LONG CKey::SetValue(LPCTSTR name, LPCTSTR value) throw()
{
  MYASSERT(value != NULL);
  MYASSERT(_object != NULL);
  return RegSetValueEx(_object, name, 0, REG_SZ,
      (const BYTE * )value, (lstrlen(value) + 1) * sizeof(TCHAR));
}
GraphicElementProjectionBase::GraphicElementProjectionBase(const ProjectionBase* projection,
                                                           bool is_moveable) :
    GraphicElementBase(is_moveable), m_projection(projection), m_projection_changed(true)
{
    MYASSERT(m_projection != 0);
    MYASSERT(connect(projection, SIGNAL(signalChanged()), this, SLOT(slotProjectionChanged())));
}
Exemple #6
0
LONG CKey::SetValue(LPCTSTR name, const void *value, UInt32 size) throw()
{
  MYASSERT(value != NULL);
  MYASSERT(_object != NULL);
  return RegSetValueEx(_object, name, 0, REG_BINARY,
      (const BYTE *)value, size);
}
Exemple #7
0
	/**
	 * Destroy a placeholder. Mark this placeholder as free
	 * and store the index in the pool of free placeholders.
	 * @param index The placeholder handle.
	 * @return Status code.
	 */
	int ResourceArray::_maDestroyPlaceholder(unsigned index) {
		// The handle must be a dynamic placeholder.
		if (!(index & DYNAMIC_PLACEHOLDER_BIT)) {
			// TODO: Use MYASSERT_IF_PANICS_ENABLED when
			// conditional panics are to be used.
			BIG_PHAT_ERROR(ERR_RES_PLACEHOLDER_NOT_DYNAMIC);
			return -2;
		}

		// Get the index into the dynamic resource array.
		unsigned i = index & (~DYNAMIC_PLACEHOLDER_BIT);
		TESTINDEX(i, mDynResSize);

		// The placeholder must not have been destroyed.
		if (RT_NIL == mDynResTypes[i])
		{
			// TODO: Use MYASSERT_IF_PANICS_ENABLED when
			// conditional panics are to be used.
			BIG_PHAT_ERROR(ERR_RES_PLACEHOLDER_ALREADY_DESTROYED);
			return -2;
		}

		// Set the handle type to RT_NIL. This marks the
		// placeholder as destroyed.
		mDynResTypes[i] = RT_NIL;

		// Put handle into the pool.

		// Create or expand the pool as needed.
		if (0 == mDynResPoolCapacity) {
			// Create the initial pool.
			mDynResPoolCapacity = 2;
			mDynResPool = new unsigned[mDynResPoolCapacity];
			MYASSERT(mDynResPool != NULL, ERR_OOM);
		}
		else if (mDynResPoolSize + 1 > mDynResPoolCapacity) {
			// Expand the pool.
			unsigned* oldDynResPool = mDynResPool;
			mDynResPool = new unsigned[mDynResPoolCapacity * 2];
			MYASSERT(mDynResPool != NULL, ERR_OOM);

			// Copy from old to new and delete old.
			memcpy(
				mDynResPool,
				oldDynResPool,
				mDynResPoolCapacity * sizeof(unsigned));
			delete []oldDynResPool;

			// Set new capacity.
			mDynResPoolCapacity = mDynResPoolCapacity * 2;
		}

		// Increment pool size.
		++mDynResPoolSize;

		// Add free handle index last in array (push to stack).
		mDynResPool[mDynResPoolSize - 1] = index;

		return RES_OK;
	}
Exemple #8
0
// Lists
void glDeleteLists(GLuint list,  GLsizei range)
{
    ListRange listRange;
    int       i;

    if(!s_pCtx)
        return;

    if(list==0)
        return;

    MYASSERT(list>=1 && int(list+range)<=s_lists.size());

    // All of the lists that are being freed should be currently allocated,
    // and we're going to mark them as not allocated
    for(i=0; i<range; i++)
    {
        // To protect ourselves against double frees in a release build,
        // don't free the list if one of the list elements isn't allocated
        if(!s_listAllocated[list+i])
        {
            *((int *)0)=0;
            return;
        }

        MYASSERT(s_listAllocated[list+i]);

        s_listAllocated[list+i]=false;
    }

    listRange.begin=list;
    listRange.size=range;

    s_availableLists.push_back(listRange);
}
Exemple #9
0
SYSCALL(void, maHttpSetRequestHeader(MAHandle conn, const char* key, const char* value)) {
	LOGS("HttpSetRequestHeader %i %s: %s\n", conn, key, value);
	MAStreamConn& mac = getStreamConn(conn);
	HttpConnection* http = mac.conn->http();
	MYASSERT(http != NULL, ERR_CONN_NOT_HTTP);
	MYASSERT(http->mState == HttpConnection::SETUP, ERR_HTTP_NOT_SETUP);
	http->SetRequestHeader(key, value);
}
Exemple #10
0
LONG CKey::QueryValue(LPCWSTR name, LPWSTR value, UInt32 &count)
{
  MYASSERT(count != NULL);
  DWORD type = 0;
  LONG res = RegQueryValueExW(_object, name, NULL, &type, (LPBYTE)value, (DWORD *)&count);
  MYASSERT((res != ERROR_SUCCESS) || (type == REG_SZ) || (type == REG_MULTI_SZ) || (type == REG_EXPAND_SZ));
  return res;
}
void GraphicElementLayerList::addElementByLayer(unsigned int layer, GraphicElementBase* element)
{
    MYASSERT(element != 0);

    addLayerWhenNotExisting(layer);
    GraphicElementList *list = m_layer_map.find(layer).value();
    MYASSERT(list != 0);
    list->addElement(element);
}
Exemple #12
0
LONG CKey::SetValue(LPCWSTR name, LPCWSTR value)
{
  MYASSERT(value != NULL);
  MYASSERT(_object != NULL);
  if (g_IsNT)
    return RegSetValueExW(_object, name, NULL, REG_SZ,
      (const BYTE * )value, (DWORD)((wcslen(value) + 1) * sizeof(wchar_t)));
  return SetValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name),
    value == 0 ? 0 : (LPCSTR)GetSystemString(value));
}
Exemple #13
0
LONG CKey::QueryValue(LPCTSTR name, UInt32 &value) throw()
{
  DWORD type = 0;
  DWORD count = sizeof(DWORD);
  LONG res = RegQueryValueEx(_object, (LPTSTR)name, NULL, &type,
    (LPBYTE)&value, &count);
  MYASSERT((res != ERROR_SUCCESS) || (type == REG_DWORD));
  MYASSERT((res != ERROR_SUCCESS) || (count == sizeof(UInt32)));
  return res;
}
Exemple #14
0
/*===========================================================================*
 *				checklist				     *
 *===========================================================================*/
static int checklist(char *file, int line,
	struct slabheader *s, int l, int bytes)
{
	struct slabdata *n = s->list_head[l];
	int ch = 0;

	while(n) {
		int count = 0, i;
		MYASSERT(n->sdh.magic1 == MAGIC1);
		MYASSERT(n->sdh.magic2 == MAGIC2);
		MYASSERT(n->sdh.list == l);
		MYASSERT(usedpages_add(n->sdh.phys, VM_PAGE_SIZE) == 0);
		if(n->sdh.prev)
			MYASSERT(n->sdh.prev->sdh.next == n);
		else
			MYASSERT(s->list_head[l] == n);
		if(n->sdh.next) MYASSERT(n->sdh.next->sdh.prev == n);
		for(i = 0; i < USEELEMENTS*8; i++)
			if(i >= ITEMSPERPAGE(bytes))
				MYASSERT(!GETBIT(n, i));
			else
				if(GETBIT(n,i))
					count++;
		MYASSERT(count == n->sdh.nused);
		ch += count;
		n = n->sdh.next;
	}

	return ch;
}
void GraphicElementLayerList::addLayerWhenNotExisting(unsigned int layer)
{
    if (m_layer_map.find(layer) == m_layer_map.end())
    {
        GraphicElementList* new_list = new GraphicElementList;
        MYASSERT(new_list);
        m_layer_map.insert(layer, new_list);
    }

    MYASSERT(m_layer_map.find(layer) != m_layer_map.end());
}
Exemple #16
0
static void chunk_getpath (const gs_chunk_t *chunk, char *cPath, size_t s)
{
	size_t cPathLen;

	MYASSERT(chunk);
	MYASSERT(cPath);

	cPathLen = snprintf (cPath, MAX(s, sizeof(chunk->ci->id.vol)), "%s/",
			chunk->ci->id.vol);
	chunk_id2str (chunk, cPath+cPathLen, s-cPathLen);
}
Exemple #17
0
    static void SOCKET_INIT(void)
    {
        WORD vreq = MAKEWORD(2,2); WSADATA wd;
	int rcode = WSAStartup(vreq,&wd);
	int ver_min_high = 1, ver_min_low = 1;
	MYASSERT( rcode == 0, ("%d",rcode) );
	MYASSERT( HIBYTE(wd.wVersion)>ver_min_high ||
	          (HIBYTE(wd.wVersion)==ver_min_high &&
	           LOBYTE(wd.wVersion)>=ver_min_low),
	          ("%d.%d",wd.wVersion,wd.wVersion) );
    }
Exemple #18
0
SYSCALL(void, maHttpFinish(MAHandle conn)) {
	MAStreamConn& mac = getStreamConn(conn);
	MYASSERT(mac.state == 0, ERR_CONN_ACTIVE);
	HttpConnection* http = mac.conn->http();
	MYASSERT(http != NULL, ERR_CONN_NOT_HTTP);
	MYASSERT(http->mState == HttpConnection::SETUP || http->mState == HttpConnection::WRITING,
		ERR_HTTP_ALREADY_FINISHED);
	mac.state = CONNOP_FINISH;
	http->mState = HttpConnection::FINISHING;
	gThreadPool.execute(new HttpFinish(mac, *http));
}
Exemple #19
0
static MAConn& getConn(MAHandle conn) {
	MAConn* macp;
	gConnMutex.lock();
	{
		MYASSERT(!gConnections.empty(), ERR_CONN_HANDLE_INVALID);
		ConnItr itr = gConnections.find(conn);
		MYASSERT(itr != gConnections.end(), ERR_CONN_HANDLE_INVALID);
		macp = itr->second;
	}
	gConnMutex.unlock();
	return *macp;
}
Exemple #20
0
void FMCConsole::registerConfigWidget(const QString& title, Config* cfg)
{
#if !VASFMC_GAUGE
    if (m_main_config->getIntValue(CFG_ENABLE_CONFIG_ACCESS) == 0) return;
    MYASSERT(!title.isEmpty());
    MYASSERT(cfg != 0);
    config_tab->addTab(new ConfigWidget(cfg), title);
#else
    Q_UNUSED(title);
    Q_UNUSED(cfg);
#endif
}
Exemple #21
0
	/**
	 * Implementation of maCreatePlaceholder.
	 * @return A placeholder handle.
	 */
	unsigned int ResourceArray::create_RT_PLACEHOLDER() {
		// Get a placeholder from the pool, if available.
		if (mDynResPoolSize > 0) {
			--mDynResPoolSize;
			unsigned handle = mDynResPool[mDynResPoolSize];
			int placeholderIndex = handle & (~DYNAMIC_PLACEHOLDER_BIT);
			mDynResTypes[placeholderIndex] = RT_PLACEHOLDER;
			return handle;
		}

		// Expand the dynamic resource array if needed.
		if (mDynResSize + 1 > mDynResCapacity) {
			void** oldPlaceholders = mDynRes;
			byte* oldPlaceholderTypes = mDynResTypes;
			mDynRes = new void*[mDynResCapacity * 2];
			MYASSERT(mDynRes != NULL, ERR_OOM);
			mDynResTypes = new byte[mDynResCapacity * 2];
			MYASSERT(mDynResTypes != NULL, ERR_OOM);
			memset(mDynRes, 0, sizeof(void*) * (mDynResCapacity * 2));

			if (oldPlaceholders != NULL) {
				// Copy from old to new.
				memcpy(
					mDynRes,
					oldPlaceholders,
					mDynResCapacity * sizeof(void*));
				memcpy(
					mDynResTypes,
					oldPlaceholderTypes,
					mDynResCapacity * sizeof(byte));

				// Delete old arrays.
				delete []oldPlaceholders;
				delete []oldPlaceholderTypes;
			}

			// Set new capacity.
			mDynResCapacity = mDynResCapacity * 2;
		}

		// This is the index of the new placeholder.
		int placeholderIndex = mDynResSize;

		// Increment placeholder array size.
		++mDynResSize;

		// Add a placeholder type to the new array item.
		mDynResTypes[placeholderIndex] = RT_PLACEHOLDER;

		// Return the handle id, this is the index of the
		// array item with the dynamic resource bit set.
		return placeholderIndex | DYNAMIC_PLACEHOLDER_BIT;
	}
bool ChartElemText::loadFromDomElement(QDomElement& dom_element, 
                                        QDomDocument& dom_doc,
                                        QString& err_msg)
{
    MYASSERT(!dom_element.isNull());
    TreeBaseXML::loadFromDomElement(dom_element, dom_doc, err_msg);
    
    if (m_dom_element.tagName() != CHART_NODE_NAME_TEXTS_TEXT)
    {
        err_msg = QString("Wrong node name (%s), expected (%s)").
                  arg(m_dom_element.tagName()).arg(CHART_NODE_NAME_TEXTS_TEXT);
        return false;
    }

    // extract the text from the node

    setTextNode(dom_element);
    QString text = m_text_node.data().trimmed();

    // extract other info from node
    
    bool draw_border = dom_element.attribute(CHART_ATTR_BORDER).toInt();
    bool is_latlon = dom_element.attribute(CHART_ATTR_ISLATLON).toInt();
    QString abs_ref_corner_text = dom_element.attribute(CHART_ATTR_REFPOINT);
    
    bool ok_x = false, ok_y = false;
    double x = dom_element.attribute(CHART_ATTR_POINT_X).toDouble(&ok_x);
    double y = dom_element.attribute(CHART_ATTR_POINT_Y).toDouble(&ok_y);    
    
    if (!ok_x || !ok_y)
    {
        err_msg = QString("Text: Could not parse X/Y (%1/%2) of tag named (%3)").
                  arg(dom_element.attribute(CHART_ATTR_POINT_X)).
                  arg(dom_element.attribute(CHART_ATTR_POINT_Y)).
                  arg(dom_element.tagName());
        return false;
    }

    // check info
    
    delete m_ge_textrect;
    m_ge_textrect = new GETextRect(m_chart_model->getProjection(), text, 
                                   QPointF(x,y), is_latlon, 
                                   GETextRect::getAbsRefCornerFromText(abs_ref_corner_text),
                                   draw_border);
    
    MYASSERT(m_ge_textrect);
    m_ge_textrect->setDataElement(this);

    m_chart_model->getGELayerList()->addElementByLayer(CHART_GE_LAYER_TEXTRECT, m_ge_textrect);
    return true;
}
Exemple #23
0
LONG CKey::Open(HKEY parentKey, LPCTSTR keyName, REGSAM accessMask) throw()
{
  MYASSERT(parentKey != NULL);
  HKEY key = NULL;
  LONG res = RegOpenKeyEx(parentKey, keyName, 0, accessMask, &key);
  if (res == ERROR_SUCCESS)
  {
    res = Close();
    MYASSERT(res == ERROR_SUCCESS);
    _object = key;
  }
  return res;
}
Exemple #24
0
void IOCPServer::slotNewConnection()
{
    QTcpSocket *client_connection = m_tcp_server->nextPendingConnection();
    m_client_socket_list.append(client_connection);
    MYASSERT(connect(client_connection, SIGNAL(disconnected()), this, SLOT(slotGotClientData())));
    MYASSERT(connect(client_connection, SIGNAL(readyRead()), this, SLOT(slotGotClientData())));

    Logger::log(QString("IOCPServer:slotNewConnection: client connected: %1:%2").
                arg(client_connection->peerAddress().toString()).
                arg(client_connection->peerPort()));

    client_connection->write(QString("Arn.TipoSer:vasFMC:CL\r\n").toAscii());
}
Exemple #25
0
GEVor::GEVor(const ProjectionBase* projection, const Vor* vor) : 
    GraphicElementProjectionBase(projection)
{
    MYASSERT(vor != 0);
    m_vor = static_cast<Vor*>(vor->copy());
    MYASSERT(m_vor != 0);
    
    QString text = 
        QString("%1 %2").arg(m_vor->getFreq()/1000.0, 0, 'f', 2).arg(m_vor->getId());
    m_label = new GELabel(m_projection, this, QPointF(0,0), text);
    MYASSERT(m_label != 0);
    m_label->setNormalColor(m_normal_color);
}
GEAirport::GEAirport(const ProjectionBase* projection, 
                     const Airport* airport) : 
    GraphicElementProjectionBase(projection)
{
    MYASSERT(airport != 0);
    m_airport = static_cast<Airport*>(airport->copy());
    MYASSERT(m_airport != 0);
    m_normal_color = m_active_color = Qt::blue;
    
    m_label = new GELabel(m_projection, this, QPointF(0,6), m_airport->getId(), false, false);
    MYASSERT(m_label != 0);
    m_label->setNormalColor(m_normal_color);
}
Exemple #27
0
/* -----------------------------------------------------------------------
 Function Name: initialize_WordNode()
 Functionality: initializes WordNode data structures and variables
 Input <--- word
 Outputs ---> creates a WordNode strucutre and returns a pointer to it
 -----------------------------------------------------------------------
*/
WordNode *initialize_word_node(char *word)
{
    //allocating memory to WordNode
    WordNode *new_word_node = calloc(1, sizeof(WordNode));
    MYASSERT(new_word_node != NULL);

    new_word_node->word = calloc(1, strlen(word) + 1);
    MYASSERT(new_word_node->word != NULL);

    strcpy(new_word_node->word, word);
    new_word_node->data = NULL; 

    return new_word_node;
}
Exemple #28
0
int Base::maAccept(MAHandle conn) {
	LOGST("Accept %i", conn);
	MAConn& mac = getConn(conn);
	MYASSERT(mac.type == eServerConn, ERR_CONN_NOT_SERVER);
#ifdef _WIN32_WCE
	DEBIG_PHAT_ERROR;
#else
	MAServerConn& masc((MAServerConn&)mac);
	MYASSERT((mac.state & CONNOP_ACCEPT) == 0, ERR_CONN_ALREADY_ACCEPTING);
	mac.state |= CONNOP_ACCEPT;
	gThreadPool.execute(new Accept(masc));
#endif	//_WIN32_WCE
	return 0;
}
Exemple #29
0
int main()
{
    {
	S x("1");
	S y("2");
    
	MYASSERT( x == "1" );
	if( count != 2 ) fail(__LINE__);
	MYASSERT( y == "1" );
	if( count != 2 ) fail(__LINE__);
    }
    if( count != 0 ) fail(__LINE__);
    _PASS;
}
Exemple #30
0
BOOLEAN
ParseMAC (MACADDR dest, const char *src)
{
  int c;
  int mac_index = 0;
  BOOLEAN high_digit = FALSE;
  int delim_action = 1;

  MYASSERT (src);
  MYASSERT (dest);

  CLEAR_MAC (dest);

  while (c = *src++)
    {
      if (IsMacDelimiter (c))
	{
	  mac_index += delim_action;
	  high_digit = FALSE;
	  delim_action = 1;
	}
      else if (IsHexDigit (c))
	{
	  const int digit = HexStringToDecimalInt (c);
	  if (mac_index < sizeof (MACADDR))
	    {
	      if (!high_digit)
		{
		  dest[mac_index] = (char)(digit);
		  high_digit = TRUE;
		  delim_action = 1;
		}
	      else
		{
		  dest[mac_index] = (char)(dest[mac_index] * 16 + digit);
		  ++mac_index;
		  high_digit = FALSE;
		  delim_action = 0;
		}
	    }
	  else
	    return FALSE;
	}
      else
	return FALSE;
    }

  return (mac_index + delim_action) >= sizeof (MACADDR);
}