This is the mail archive of the ecos-bugs@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001634] A code review of dlmalloc.cxx revealed severalweaknesses


Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001634

--- Comment #1 from Bernd Edlinger <bernd.edlinger@hotmail.de> 2012-07-27 10:12:03 BST ---
This is a test code to demonstrate the very slow performance
of the current implementation. The parameter k is the number
of kilobytes to use for the test.

The execution time of memtest(n) = O(n^2) without the patch.
When the patch is applied the execution time will be O(n).

#include <malloc.h>
void memtest(unsigned k)
{
    unsigned i;
    void **p,**q;
    p=q=malloc(504);
    for (i=0; i<k; i++)
    {
        q=*q=malloc(504+4*(i%16));
    }
    *q=0;
    q=p;
    for (i=0; i<k; i++)
    {
        void **n=*q;
        q=*q=*n;
        free(n);
        if (!q || !*q) q=p;
    }
    free(p);
}

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]