avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[3]: [avr-libc-dev] malloc implementation


From: Bertolt Mildner
Subject: Re[3]: [avr-libc-dev] malloc implementation
Date: Fri, 17 Dec 2004 16:50:46 +0100

Hi Joerg,

Some minor corrections:

>         if (len < sizeof(struct __freelist) - sizeof(size_t))
>                 len = sizeof(struct __freelist) - sizeof(size_t);

         if (len < sizeof(struct __freelist) - sizeof(current->sz))
                 len = sizeof(struct __freelist) - sizeof(current->sz);

Is there really no better way to get the size of a struct member?
I really feel like "sizeof(struct __freelist.sz)" should be legal!?

>           if ((current->sz >= len) &&
>               ((current->sz == len) ||
>                (size == 0) ||
>                ((size != 0) &&
>                 (size > current->sz))))

           if ((current->sz >= len) &&
               ((current->sz == len) ||
                (size == 0) ||
                (size > current->sz)))

>           else /* split current */
>           {
>             /* resize remaining entry */
>             candidate->sz -= len + sizeof(struct __freelist.sz);

             candidate->sz -= len + sizeof(current->sz);

>         /*
>          * Both tests below are needed to catch the case len >= 0xfffe.
>          */
>         if (size >= len && size >= len + sizeof(size_t)) {
>                 current = (struct freelist *)__brkval;
>                 __brkval += len + sizeof(size_t);

         if (size >= len && size >= len + sizeof(current->sz)) {
                 current = (struct freelist *)__brkval;
                 __brkval += len + sizeof(current->sz);

>          * Step 4: There's no help, just fail. :-/
          * Step 3: There's no help, just fail. :-/

Bertolt

-- 
Best regards,
 Bertolt                            mailto:address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]