Пример #1
0
utString& utString::operator+=(const utString& s)
{
    const size_type lenp = strlen(p);
    const size_type lens = strlen(s.p) + 1;
    p = static_cast<char*>(lmRealloc(NULL, p, lenp + lens)); // could return NULL
    memmove(p + lenp, s.p, lens); // p and s.p MAY overlap
    return *this;
}
Пример #2
0
    // Make sure we have enough room to write freeBytes, and grow the buffer
    // if we don't.
    void ensureBuffer(unsigned int freeBytes)
    {
        // Nop if enough free space.
        if(offset+freeBytes<ndata)
            return;

        ndata = offset + freeBytes; // Resize to requested size
        ndata += ndata / 2; // Allocate 0.5x more
        if (ndata < 4096) ndata = 4096;

        data = (unsigned char*)lmRealloc(NULL, data, ndata);

    }
Пример #3
0
static void *lsLuaAlloc(void *ud, void *ptr, size_t osize, size_t nsize)
{
    (void)ud;  (void)osize;  /* not used */
    if (nsize == 0 && ptr) 
    {
        lmFree(NULL, ptr);
        return NULL;
    }
    else
    {
        if(osize == 0)
            return lmAlloc(NULL, nsize);
        else
            return lmRealloc(NULL, ptr, nsize);
    }
}
Пример #4
0
utString& utString::erase(size_type pos, size_type len)
{
    size_type s = size();

    if (pos > s)
    {
        abort();
    }

    s -= pos;
    if (len > s)
    {
        len = s;
    }
    ++s;

    // erase by overwriting
    memmove(p + pos, p + pos + len, s);

    // remove unused space
    p = static_cast<char*>(lmRealloc(NULL, p, s + pos));

    return *this;
}
Пример #5
0
static void* customRealloc(void* mem, size_t size) { return lmRealloc(NULL, mem, size); }