예제 #1
0
파일: qsggeometry.cpp 프로젝트: RS102839/qt
void QSGGeometry::allocate(int vertexCount, int indexCount)
{
    if (vertexCount == m_vertex_count && indexCount == m_index_count)
        return;

    m_vertex_count = vertexCount;
    m_index_count = indexCount;

    bool canUsePrealloc = m_index_count <= 0;
    int vertexByteSize = m_attributes.stride * m_vertex_count;

    if (m_owns_data)
        qFree(m_data);

    if (canUsePrealloc && vertexByteSize <= (int) sizeof(m_prealloc)) {
        m_data = (void *) &m_prealloc[0];
        m_index_data_offset = -1;
        m_owns_data = false;
    } else {
        Q_ASSERT(m_index_type == GL_UNSIGNED_INT || m_index_type == GL_UNSIGNED_SHORT);
        int indexByteSize = indexCount * (m_index_type == GL_UNSIGNED_SHORT ? sizeof(quint16) : sizeof(quint32));
        m_data = (void *) qMalloc(vertexByteSize + indexByteSize);
        m_index_data_offset = vertexByteSize;
        m_owns_data = true;
    }

}
예제 #2
0
/*!
    Returns the connection types associated with a signal or slot \a member
    specification.  The array of types is returned from this function,
    and the number of arguments is returned in \a nargs.  Returns null
    if \a member is invalid.  The return value must be freed with qFree().
*/
int *QSignalIntercepter::connectionTypes( const QByteArray& member, int& nargs )
{
    // Based on Qt's internal queuedConnectionTypes function.
    nargs = 0;
    int *types = 0;
    const char *s = member.constData();
    while (*s != '\0' && *s != '(') { ++s; }
    if ( *s == '\0' )
        return 0;
    ++s;
    const char *e = s;
    while (*e != ')') {
        ++e;
        if (*e == ')' || *e == ',')
            ++nargs;
    }

    types = (int *) qMalloc((nargs+1)*sizeof(int));
    types[nargs] = 0;
    for (int n = 0; n < nargs; ++n) {
        e = s;
        while (*s != ',' && *s != ')')
            ++s;
        QByteArray type(e, s-e);
        ++s;

        types[n] = typeFromName(type);
        if (!types[n]) {
            qWarning("QSignalIntercepter::connectionTypes: Cannot marshal arguments of type '%s'", type.data());
            qFree(types);
            return 0;
        }
    }
    return types;
}
예제 #3
0
파일: cookie.c 프로젝트: berte/mediaplayer
int main(void) {
  char *mode, *name, *value;

  mode = qValue("mode");
  name = qValue("cname");
  value = qValue("cvalue");

  if(mode == NULL) { /* View Cookie */
    int amount;
    qContentType("text/html");
    amount = qPrint();
    printf("<p>Total %d entries\n", amount);
  }
  else if(!strcmp(mode, "set")) { /* Set Cookie */
    if(name == NULL || value == NULL) qError("Query not found");
    if(!strcmp(name, "")) qError("Empty cookie name can not be stored.");

    qCookieSet(name, value, 0, NULL, NULL, NULL);
    qContentType("text/html");
    printf("Cookie('%s'='%s') entry is stored.<br>Click <a href='%s'>here</a> to view your cookies\n", name, value, qCGIname());
  }
  else if(!strcmp(mode, "remove")) { /* Remove Cookie */
    if(name == NULL) qError("Query not found");
    if(!strcmp(name, "")) qError("Empty cookie name can not be removed.");

    qCookieRemove(name, NULL, NULL, NULL);
    qContentType("text/html");
    printf("Cookie('%s') entry is removed.<br>Click <a href='%s'>here</a> to view your cookies\n", name, qCGIname());
  }
  else qError("Unknown mode.");

  qFree();
  return 0;
}
예제 #4
0
파일: qvector.cpp 프로젝트: 13W/phantomjs
void QVectorData::free(QVectorData *x, int alignment)
{
    if (alignment > alignmentThreshold())
        qFreeAligned(x);
    else
        qFree(x);
}
예제 #5
0
파일: qpixmap_win.cpp 프로젝트: phen89/rtqt
static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
{
    BITMAPINFO bmi;
    memset(&bmi, 0, sizeof(bmi));
    bmi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth       = w;
    bmi.bmiHeader.biHeight      = -h;
    bmi.bmiHeader.biPlanes      = 1;
    bmi.bmiHeader.biBitCount    = 32;
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biSizeImage   = w * h * 4;

    QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
    if (image.isNull())
        return image;

    // Get bitmap bits
    uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);

    if (GetDIBits(hdc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {
        // Create image and copy data into image.
        for (int y=0; y<h; ++y) {
            void *dest = (void *) image.scanLine(y);
            void *src = data + y * image.bytesPerLine();
            memcpy(dest, src, image.bytesPerLine());
        }
    } else {
        qWarning("qt_fromWinHBITMAP(), failed to get bitmap bits");
    }
    qFree(data);

    return image;
}
예제 #6
0
/*!
    Destroys the ConverterState object.
*/
QTextCodec::ConverterState::~ConverterState()
{
    if (flags & FreeFunction)
        (QTextCodecUnalignedPointer::decode(state_data))(this);
    else if (d)
        qFree(d);
}
예제 #7
0
파일: arglist.c 프로젝트: berte/mediaplayer
int main(void) {
  char *string, *query;
  char *qlist[256], **qp;
  int queries, tmatches, matches;

  qContentType("text/html");
  qDecoder();

  string = qValueNotEmpty("Type any string.", "string");
  query = qValueNotEmpty("Type any query.", "query");

  queries = qArgMake(query, qlist);
  matches = qArgMatch(string, qlist);

  printf("String: <b>%s</b><br>\n", string);
  printf("Query Input: <b>%s</b><br>\n", query);

  printf("<hr>\n");

  printf("qArgMake(): <b>");
  for(qp = qlist; *qp; qp++) qPrintf(1, "\"%s\" ", *qp);
  printf("</b> (%d queries)<br>\n", queries);
  printf("qArgEmprint(): "); tmatches = qArgEmprint(1, string, qlist); printf(" (%d query matched)<br>\n", tmatches);
  printf("qArgMatch(): %d query matched<br>\n", matches);

  qArgFree(qlist);
  qFree();
  return 0;
}
예제 #8
0
파일: dosipx.cpp 프로젝트: zlatkok/swospp
/** DismissIncomingPackets

    Discards any received packet at the same time confirming any pending packet should the
    acknowledgement arrive.
*/
void DismissIncomingPackets()
{
    int length;
    IPX_Address node;

    while (char *packet = ReceivePacket(&length, &node))
        qFree(packet);
}
QDeclarative1OpenMetaObjectType::~QDeclarative1OpenMetaObjectType()
{
    if (d->mem)
        qFree(d->mem);
    if (d->cache)
        d->cache->release();
    delete d;
}
예제 #10
0
파일: dosipx.cpp 프로젝트: zlatkok/swospp
static void RemoveFragmentList(FragmentLink *p, FragmentLink *prev)
{
    if (p) {
        Fragment *q = p->first.next;
        while (q) {
            Fragment *next = q->next;
            qFree(q);
            q = next;
        }

        if (prev)
            prev->next = p->next;
        else
            m_fragmentList = p->next;

        qFree(p);
    }
}
예제 #11
0
파일: dosipx.cpp 프로젝트: zlatkok/swospp
/* Mark whole pool free. */
void FreeAllUnAck()
{
    UnAckPacket *p = m_unAckList;
    while (p) {
        UnAckPacket *next = p->next;
        qFree(p);
        p = next;
    }

    m_unAckList = nullptr;
}
예제 #12
0
파일: qmap.cpp 프로젝트: Fale/qtmoko
void QMapData::continueFreeData(int offset)
{
    Node *e = reinterpret_cast<Node *>(this);
    Node *cur = e->forward[0];
    Node *prev;
    while (cur != e) {
        prev = cur;
        cur = cur->forward[0];
        qFree(reinterpret_cast<char *>(prev) - offset);
    }
    delete this;
}
예제 #13
0
파일: qmap.cpp 프로젝트: Fale/qtmoko
void QMapData::node_delete(Node *update[], int offset, Node *node)
{
    node->forward[0]->backward = node->backward;

    for (int i = 0; i <= topLevel; ++i) {
        if (update[i]->forward[i] != node)
            break;
        update[i]->forward[i] = node->forward[i];
    }
    --size;
    qFree(reinterpret_cast<char *>(node) - offset);
}
예제 #14
0
파일: dosipx.cpp 프로젝트: zlatkok/swospp
void ShutDownNetwork()
{
    if (m_lowMemory) {
        CancelPackets();
        IPX_CloseSocket(m_socketId);
        qFree(m_clientAckIds);
        m_clientAckIds = nullptr;
        ReleaseFragmentedPackets();
        WriteToLog("Releasing low memory, ptr is %#x", m_lowMemory);
        FreeLowMemory(m_lowMemory);
        m_lowMemory = nullptr;
    }
}
예제 #15
0
파일: qStack.c 프로젝트: qiweiyu/cutil
void *qStackPop(qStack *stack) {
	qLinkListNode *node = stack->list->tail;
	if(node == NULL)
		return NULL;
	stack->list->tail = node->prev;
	if(node->prev) {
		node->prev->next = NULL;
	}
	else {
		stack->list->head = NULL;
	}
	void *val = node->value;
	qFree(node);
	return val;
}
예제 #16
0
파일: dosipx.cpp 프로젝트: zlatkok/swospp
/* Delete all unconfirmed packets for this ipx address. */
static void ClearClientUnAckQueue(const IPX_Address *node)
{
    UnAckPacket *p = m_unAckList, **prev = &m_unAckList;
    //WriteToLog("Clearing unack queue for [%#.12s]", node);

    while (p) {
        UnAckPacket *next = p->next;
        if (AddressMatch(node, &p->address)) {
            *prev = next;
            qFree(p);
        } else
            prev = &p->next;
        p = next;
    }
}
예제 #17
0
int main(void) {
  char *list;

  qDecoder();

  qContentType("text/html");
  if((list = qValueFirst("checklist")) == NULL) qError("Check what you want to order please.");
  printf("You ordered ");
  for(; list; list = qValueNext()) {
    printf("<b>%s</b> \n", list);
  }

  qFree();
  return 0;
}
예제 #18
0
파일: dosipx.cpp 프로젝트: zlatkok/swospp
/* If dest/id in list, remove the packet */
static void AcknowledgePacket(dword id, const IPX_Address *dest)
{
    UnAckPacket *p, **prev = &m_unAckList;
    //WriteToLog("Packet with id %d for [%#.12s] confirmed.", id, dest);

    for (p = m_unAckList; p; p = p->next) {
        if (*p->data == id && AddressMatch(&p->address, dest))
            break;
        prev = &p->next;
    }

    if (p) {
        *prev = p->next;
        qFree(p);
    }
}
예제 #19
0
const char *SettingsWidget::lookForWidgetState(QWidget *widget, const char *property, const char *signal)
{
	const QMetaObject *meta = widget->metaObject();
	WidgetInfo info = { widget, NULL, QVariant(), false };
	bool free_signal = false;
	// Firstly try to search this widget in predefined classes
	if (!signal && !property) {
		for (int i = 0, size = sizeof(widget_infos) / sizeof(AbstractWidgetInfo*); i < size; i++) {
			if (widget_infos[i]->handle(widget)) {
				info.property = widget_infos[i]->property;
				signal = widget_infos[i]->signal;
				break;
			}
		}
	}
	// Then try to find "User" property with signal or signal by property
	if (!signal) {
		for (int i = 0, size = meta->propertyCount(); i < size; i++) {
			QMetaProperty prop = meta->property(i);
			if (prop.hasNotifySignal()
				&& ((property && !qstrcmp(prop.name(), property))
					|| (!property && prop.isUser()))) {
				info.property = prop.name();
				const char *sig = prop.notifySignal().signature();
				int len = strlen(sig);
				char *str = (char *)qMalloc(sizeof(char) * (len + 2));
				str[0] = QSIGNAL_CODE;
				qstrcpy(str + 1, sig);
				signal = str;
				free_signal = true;
				break;
			}
		}
	}
	bool result(signal);
	if (result) {
		p->mapper->setMapping(widget, p->infos.size());
		connect(widget, signal, p->mapper, SLOT(map()));
		p->infos << info;
	}
	if (free_signal)
		qFree((void *)signal);
	return result ? info.property : 0;
}
int QDeclarative1OpenMetaObjectType::createProperty(const QByteArray &name)
{
    int id = d->mob.propertyCount();
    d->mob.addSignal("__" + QByteArray::number(id) + "()");
    QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
    propertyCreated(id, build);
    qFree(d->mem);
    d->mem = d->mob.toMetaObject();
    d->names.insert(name, id);
    QSet<QDeclarative1OpenMetaObject*>::iterator it = d->referers.begin();
    while (it != d->referers.end()) {
        QDeclarative1OpenMetaObject *omo = *it;
        *static_cast<QMetaObject *>(omo) = *d->mem;
        if (d->cache)
            d->cache->update(d->engine, omo);
        ++it;
    }

    return d->propertyOffset + id;
}
예제 #21
0
QList<int> QAudioDeviceInfoInternal::supportedChannelCounts()
{
    QList<int>  rc;

    // Can mix down to 1 channel
    rc << 1;

    UInt32  propSize = 0;
    int     channels = 0;

    if (AudioDeviceGetPropertyInfo(deviceId, 
                                    0,
                                    mode == QAudio::AudioInput,
                                    kAudioDevicePropertyStreamConfiguration,
                                    &propSize, 
                                    0) == noErr) {

        AudioBufferList* audioBufferList = static_cast<AudioBufferList*>(qMalloc(propSize));

        if (audioBufferList != 0) {
            if (AudioDeviceGetProperty(deviceId, 
                                        0,
                                        mode == QAudio::AudioInput,
                                        kAudioDevicePropertyStreamConfiguration,
                                        &propSize,
                                        audioBufferList) == noErr) {

                for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) {
                    channels += audioBufferList->mBuffers[i].mNumberChannels;
                    rc << channels;
                }
            }

            qFree(audioBufferList);
        }
    }

    return rc;
}
예제 #22
0
QString andrq::getString(QDataStream &in, int key)
{
	qint32 len;
	in >> len;
	char *data = (char *)qMalloc(len);
	in.readRawData(data, len);
	int dh = 0, dl = 0;

	int temp = key;
	dl |= temp & 0x000000FF;
	temp >>= 20;
	dh |= temp & 0x000000FF;

/*	if (!ans)
		return false;*/

	int ah = 184; //10111000b;
	for (int i = 0; i < len; ++i)
	{
		int al = uchar(data[i]);
		al ^= ah;

		al=(al%32)*8+al/32;	//циклический сдвиг al на 3 бита влево

		al ^= dh;
		al -= dl;

		data[i] = char(al);
		ah=(ah%8)*32+ah/8;	//циклический сдвиг ah вправо на 3 бита
	}
	static QTextCodec *ansii_codec = QTextCodec::codecForName("cp1251");
	static QTextCodec *utf8_codec = QTextCodec::codecForName("utf-8");
	QTextCodec *codec = isValidUtf8(QByteArray::fromRawData(data, len)) ? utf8_codec : ansii_codec;
	QString result = codec->toUnicode(data, len);
	qFree(data);
	return result;
}
예제 #23
0
QString QHostInfo::localDomainName()
{
#if !defined(Q_OS_VXWORKS)
    resolveLibrary();
    if (local_res_ninit) {
        // using thread-safe version
        res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state)));
        Q_CHECK_PTR(state);
        memset(state, 0, sizeof(*state));
        local_res_ninit(state);
        QString domainName = QUrl::fromAce(state->defdname);
        if (domainName.isEmpty())
            domainName = QUrl::fromAce(state->dnsrch[0]);
        local_res_nclose(state);
        qFree(state);

        return domainName;
    }

    if (local_res_init && local_res) {
        // using thread-unsafe version

#if defined(QT_NO_GETADDRINFO)
        // We have to call res_init to be sure that _res was initialized
        // So, for systems without getaddrinfo (which is thread-safe), we lock the mutex too
        QMutexLocker locker(::getHostByNameMutex());
#endif
        local_res_init();
        QString domainName = QUrl::fromAce(local_res->defdname);
        if (domainName.isEmpty())
            domainName = QUrl::fromAce(local_res->dnsrch[0]);
        return domainName;
    }
#endif
    // nothing worked, try doing it by ourselves:
    QFile resolvconf;
#if defined(_PATH_RESCONF)
    resolvconf.setFileName(QFile::decodeName(_PATH_RESCONF));
#else
    resolvconf.setFileName(QLatin1String("/etc/resolv.conf"));
#endif
    if (!resolvconf.open(QIODevice::ReadOnly))
        return QString();       // failure

    QString domainName;
    while (!resolvconf.atEnd()) {
        QByteArray line = resolvconf.readLine().trimmed();
        if (line.startsWith("domain "))
            return QUrl::fromAce(line.mid(sizeof "domain " - 1).trimmed());

        // in case there's no "domain" line, fall back to the first "search" entry
        if (domainName.isEmpty() && line.startsWith("search ")) {
            QByteArray searchDomain = line.mid(sizeof "search " - 1).trimmed();
            int pos = searchDomain.indexOf(' ');
            if (pos != -1)
                searchDomain.truncate(pos);
            domainName = QUrl::fromAce(searchDomain);
        }
    }

    // return the fallen-back-to searched domain
    return domainName;
}
예제 #24
0
QServiceProxy::~QServiceProxy()
{
    if (d->meta)
        qFree(d->meta);
    delete d;
}
예제 #25
0
파일: qStack.c 프로젝트: qiweiyu/cutil
void qFreeStack(qStack *stack) {
	qFreeLinkList(stack->list);
	qFree(stack);
}
예제 #26
0
 ~QSlotInvokerPrivate()
 {
     if ( types )
         qFree( types );
 }
예제 #27
0
SyntaxChecker::~SyntaxChecker()
{
    if (stack_size) {
        qFree(state_stack);
    }
}
예제 #28
0
파일: qsggeometry.cpp 프로젝트: RS102839/qt
QSGGeometry::~QSGGeometry()
{
    if (m_owns_data)
        qFree(m_data);
}
예제 #29
0
 ~QSignalIntercepterPrivate()
 {
     if ( types )
         qFree( types );
 }
예제 #30
0
파일: qpixmap_win.cpp 프로젝트: phen89/rtqt
QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
{
    // Verify size
    BITMAP bitmap_info;
    memset(&bitmap_info, 0, sizeof(BITMAP));

    int res = GetObject(bitmap, sizeof(BITMAP), &bitmap_info);
    if (!res) {
        qErrnoWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap info");
        return QPixmap();
    }
    int w = bitmap_info.bmWidth;
    int h = bitmap_info.bmHeight;

    BITMAPINFO bmi;
    memset(&bmi, 0, sizeof(bmi));
    bmi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth       = w;
    bmi.bmiHeader.biHeight      = -h;
    bmi.bmiHeader.biPlanes      = 1;
    bmi.bmiHeader.biBitCount    = 32;
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biSizeImage   = w * h * 4;

    QImage result;
    // Get bitmap bits
    uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);

    HDC display_dc = GetDC(0);
    if (GetDIBits(display_dc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {

        QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied;
        uint mask = 0;
        if (format == NoAlpha) {
            imageFormat = QImage::Format_RGB32;
            mask = 0xff000000;
        }

        // Create image and copy data into image.
        QImage image(w, h, imageFormat);
        if (!image.isNull()) { // failed to alloc?
            int bytes_per_line = w * sizeof(QRgb);
            for (int y=0; y<h; ++y) {
                QRgb *dest = (QRgb *) image.scanLine(y);
                const QRgb *src = (const QRgb *) (data + y * bytes_per_line);
                for (int x=0; x<w; ++x) {
                    const uint pixel = src[x];
                    if ((pixel & 0xff000000) == 0 && (pixel & 0x00ffffff) != 0)
                        dest[x] = pixel | 0xff000000;
                    else
                        dest[x] = pixel | mask;
                }
            }
        }
        result = image;
    } else {
        qWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap bits");
    }
    ReleaseDC(0, display_dc);
    qFree(data);
    return fromImage(result);
}