⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inter.c

📁 debug source code under unix platform.
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (memhead.epilogue && (memhead.recur == 1))        memhead.epilogue(p, s, t, u, i.addr);    if (p == NULL)    {        if ((z == 0) && (memhead.nomemory))        {            /* Call the low-memory handler if no memory block was allocated.             */            memhead.nomemory(s, t, u, i.addr);            if (memhead.prologue && (memhead.recur == 1))                memhead.prologue((void *) -1, l, __mp_fixalign(&memhead, f, a),                                 s, t, u, i.addr);            if ((f != AT_NEW) && (f != AT_NEWVEC))                z = 1;            goto retry;        }        if ((f == AT_ALLOCA) || (f == AT_XMALLOC) || (f == AT_XCALLOC))        {            /* The alloca(), xmalloc() and xcalloc() functions should always             * return non-NULL pointers, which means we must abort here.             */            __mp_printsummary(&memhead);            __mp_diag("\n");            __mp_error(ET_OUTMEM, f, t, u, NULL);            memhead.fini = 1;            __mp_abort();        }    }    restoresignals();    return p;}/* Allocate a new block of memory to duplicate a string. */MP_APIchar *__mp_strdup(char *p, size_t l, alloctype f, char *s, char *t, unsigned long u,            size_t k){    char *o;    stackinfo i;    loginfo v;    size_t n;    int j, z;#if TARGET == TARGET_UNIX || TARGET == TARGET_WINDOWS    /* If the C run-time library has not finished initialising then we must     * allocate new memory with sbrk() and copy the string to the new     * allocation.     */    if (!crt_initialised())    {        if (p == NULL)            o = NULL;        else        {            n = strlen(p);            if (((f == AT_STRNDUP) || (f == AT_STRNSAVE) ||                 (f == AT_STRNDUPA)) && (n > l))                n = l;            if ((o = (char *) sbrk(n + 1)) == (void *) -1)                o = NULL;            else            {                __mp_memcopy(o, p, n);                o[n] = '\0';            }        }        if ((o == NULL) && ((f == AT_STRDUPA) || (f == AT_STRNDUPA) ||             (f == AT_XSTRDUP)))            abort();        return o;    }#endif /* TARGET */    savesignals();    if (!memhead.init)        __mp_init();    if (__mp_processid() != memhead.pid)        __mp_reinit();    /* Determine the call stack details.     */    __mp_newframe(&i, NULL);    if (__mp_getframe(&i))    {        j = __mp_getframe(&i);        while ((k > 0) && (j != 0))        {            j = __mp_getframe(&i);            k--;        }    }    /* If no filename was passed through then attempt to read any debugging     * information to determine the source location of the call.     */    if ((memhead.recur == 1) && (t == NULL) && (i.addr != NULL) &&        __mp_findsource(&memhead.syms, (char *) i.addr - 1, &s, &t, &u))    {        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READWRITE);        if (s != NULL)            s = __mp_addstring(&memhead.syms.strings, s);        if (t != NULL)            t = __mp_addstring(&memhead.syms.strings, t);        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READONLY);    }    if (memhead.prologue && (memhead.recur == 1))        memhead.prologue(p, (size_t) -2, 1, s, t, u, i.addr);    v.ltype = LT_MAX;    v.type = f;    v.func = s;    v.file = t;    v.line = u;    v.stack = &i;    v.typestr = "char";    v.typesize = sizeof(char);    v.logged = 0;    checkheap(&v, memhead.count + 1);    checkalloca(&v, 0);    memhead.event++;    o = p;    z = 0;  retry:    if ((f == AT_STRNDUP) || (f == AT_STRNSAVE) || (f == AT_STRNDUPA))        j = 1;    else        j = 0;    n = l;    /* If the string is not NULL and does not overflow any memory blocks then     * allocate the memory and copy the string to the new allocation.     */    if (__mp_checkstring(&memhead, o, &n, &v, j))    {        if (p = (char *) __mp_getmemory(&memhead, n + 1, 1, &v))        {            __mp_memcopy(p, o, n);            p[n] = '\0';        }    }    else        p = NULL;    if (memhead.epilogue && (memhead.recur == 1))        memhead.epilogue(p, s, t, u, i.addr);    if (p == NULL)    {        if ((z == 0) && memhead.nomemory)        {            /* Call the low-memory handler if no memory block was allocated.             */            memhead.nomemory(s, t, u, i.addr);            if (memhead.prologue && (memhead.recur == 1))                memhead.prologue(o, (size_t) -2, 1, s, t, u, i.addr);            z = 1;            goto retry;        }        if ((f == AT_STRDUPA) || (f == AT_STRNDUPA) || (f == AT_XSTRDUP))        {            /* The strdupa(), strndupa() and xstrdup() functions should always             * return a non-NULL pointer, which means we must abort here.             */            __mp_printsummary(&memhead);            __mp_diag("\n");            __mp_error(ET_OUTMEM, f, t, u, NULL);            memhead.fini = 1;            __mp_abort();        }    }    restoresignals();    return p;}/* Resize an existing block of memory to a new size and alignment. */MP_APIvoid *__mp_realloc(void *p, size_t l, size_t a, alloctype f, char *s, char *t,             unsigned long u, char *g, size_t h, size_t k){    void *q;    stackinfo i;    loginfo v;    int j, z;#if TARGET == TARGET_UNIX || TARGET == TARGET_WINDOWS    /* If the C run-time library has not finished initialising then we must     * allocate new memory with sbrk() and copy the old contents to the new     * allocation.  We can't free the old allocation as we know nothing     * about it.     */    if (!crt_initialised())    {        if (p == NULL)        {            if (l == 0)                l = 1;            if ((q = sbrk(l)) == (void *) -1)                q = NULL;            else if (f == AT_RECALLOC)                __mp_memset(q, 0, l);        }        else if ((l == 0) || (f == AT_EXPAND) || ((q = sbrk(l)) == (void *) -1))            q = NULL;        else            __mp_memcopy(q, p, l);        if (q == NULL)            if (f == AT_REALLOCF)                free(p);            else if (f == AT_XREALLOC)                abort();        return q;    }#endif /* TARGET */    savesignals();    if (!memhead.init)        __mp_init();    if (__mp_processid() != memhead.pid)        __mp_reinit();    /* Determine the call stack details.     */    __mp_newframe(&i, NULL);    if (__mp_getframe(&i))    {        j = __mp_getframe(&i);        while ((k > 0) && (j != 0))        {            j = __mp_getframe(&i);            k--;        }    }    /* If no filename was passed through then attempt to read any debugging     * information to determine the source location of the call.     */    if ((memhead.recur == 1) && (t == NULL) && (i.addr != NULL) &&        __mp_findsource(&memhead.syms, (char *) i.addr - 1, &s, &t, &u))    {        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READWRITE);        if (s != NULL)            s = __mp_addstring(&memhead.syms.strings, s);        if (t != NULL)            t = __mp_addstring(&memhead.syms.strings, t);        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READONLY);    }    if (memhead.prologue && (memhead.recur == 1))        memhead.prologue(p, l, __mp_fixalign(&memhead, f, a), s, t, u, i.addr);    v.ltype = LT_MAX;    v.type = f;    v.func = s;    v.file = t;    v.line = u;    v.stack = &i;    v.typestr = g;    v.typesize = h;    v.logged = 0;    checkheap(&v, memhead.count);    checkalloca(&v, 0);    memhead.event++;    if ((f == AT_XREALLOC) && (l == 0) && (h != 0))        l = h;    q = p;    z = 0;  retry:    p = __mp_resizememory(&memhead, q, l, a, &v);    if (memhead.epilogue && (memhead.recur == 1))        memhead.epilogue(p, s, t, u, i.addr);    if (p == NULL)    {        if ((z == 0) && memhead.nomemory)        {            /* Call the low-memory handler if no memory block was allocated.             */            memhead.nomemory(s, t, u, i.addr);            if (memhead.prologue && (memhead.recur == 1))                memhead.prologue(q, l, __mp_fixalign(&memhead, f, a), s, t, u,                                 i.addr);            z = 1;            goto retry;        }        if (f == AT_XREALLOC)        {            /* The xrealloc() function should always return a non-NULL pointer,             * which means we must abort here.             */            __mp_printsummary(&memhead);            __mp_diag("\n");            __mp_error(ET_OUTMEM, f, t, u, NULL);            memhead.fini = 1;            __mp_abort();        }    }    restoresignals();    return p;}/* Free an existing block of memory. */MP_APIvoid__mp_free(void *p, alloctype f, char *s, char *t, unsigned long u, size_t k){    stackinfo i;    loginfo v;    int j;#if TARGET == TARGET_UNIX || TARGET == TARGET_WINDOWS    /* If the C run-time library has not finished initialising then just     * return since we know nothing about any of the prior allocations anyway.     */    if (!crt_initialised() || memhead.fini)#else /* TARGET */    if (memhead.fini)#endif /* TARGET */        return;    savesignals();    if (!memhead.init)        __mp_init();    if (__mp_processid() != memhead.pid)        __mp_reinit();    /* Determine the call stack details.     */    __mp_newframe(&i, NULL);    if (__mp_getframe(&i))    {        j = __mp_getframe(&i);        while ((k > 0) && (j != 0))        {            j = __mp_getframe(&i);            k--;        }    }    /* If no filename was passed through then attempt to read any debugging     * information to determine the source location of the call.     */    if ((memhead.recur == 1) && (t == NULL) && (i.addr != NULL) &&        __mp_findsource(&memhead.syms, (char *) i.addr - 1, &s, &t, &u))    {        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READWRITE);        if (s != NULL)            s = __mp_addstring(&memhead.syms.strings, s);        if (t != NULL)            t = __mp_addstring(&memhead.syms.strings, t);        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READONLY);    }    if (memhead.prologue && (memhead.recur == 1))        memhead.prologue(p, (size_t) -1, 0, s, t, u, i.addr);    v.ltype = LT_MAX;    v.type = f;    v.func = s;    v.file = t;    v.line = u;    v.stack = &i;    v.typestr = NULL;    v.typesize = 0;    v.logged = 0;    checkheap(&v, memhead.count);    checkalloca(&v, 0);    memhead.event++;    __mp_freememory(&memhead, p, &v);    if (memhead.epilogue && (memhead.recur == 1))        memhead.epilogue((void *) -1, s, t, u, i.addr);    restoresignals();}/* Set a block of memory to contain a specific byte. */MP_APIvoid *__mp_setmem(void *p, size_t l, unsigned char c, alloctype f, char *s, char *t,            unsigned long u, size_t k){    stackinfo i;    loginfo v;    int j;    if (!memhead.init || memhead.fini)    {        __mp_memset(p, c, l);        return p;    }    savesignals();    if (__mp_processid() != memhead.pid)        __mp_reinit();    /* Determine the call stack details.     */    __mp_newframe(&i, NULL);    if (__mp_getframe(&i))    {        j = __mp_getframe(&i);        while ((k > 0) && (j != 0))        {            j = __mp_getframe(&i);            k--;        }    }    /* If no filename was passed through then attempt to read any debugging     * information to determine the source location of the call.     */    if ((memhead.recur == 1) && (t == NULL) && (i.addr != NULL) &&        __mp_findsource(&memhead.syms, (char *) i.addr - 1, &s, &t, &u))    {        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READWRITE);        if (s != NULL)            s = __mp_addstring(&memhead.syms.strings, s);        if (t != NULL)            t = __mp_addstring(&memhead.syms.strings, t);        if (!(memhead.flags & FLG_NOPROTECT))            __mp_protectstrtab(&memhead.syms.strings, MA_READONLY);    }    v.ltype = LT_MAX;    v.type = f;    v.func = s;    v.file = t;    v.line = u;    v.stack = &i;    v.typestr = NULL;    v.typesize = 0;    v.logged = 0;    checkalloca(&v, 0);    __mp_setmemory(&memhead, p, l, c, &v);    restoresignals();    return p;}/* Copy a block of memory from one address to another. */MP_APIvoid *__mp_copymem(void *p, void *q, size_t l, unsigned char c, alloctype f, char *s,             char *t, unsigned long u, size_t k){    void *r;    stackinfo i;    loginfo v;    int j;    if (!memhead.init || memhead.fini)        if (f == AT_MEMCCPY)        {            if (r = __mp_memfind(p, l, &c, 1))                l = (size_t) ((char *) r - (char *) p) + 1;            __mp_memcopy(q, p, l);            if (r != NULL)                return (char *) q + l;            else                return NULL;        }        else        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -