This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

Re: Huge numbers for incr passed to _sbrk


Hello!

Your implementation of sbrk() is actually wrong. It should return
`highest_addr` value from _BEFORE_ it was incremented. For an example
see here:

https://github.com/DISTORTEC/distortos/blob/master/source/newlib/sbrk_r.cpp

In your case you should make a copy of original `highest_addr` value,
do some checking (also before actually modifying `highest_addr`) and
only then increment `highest_addr`. The returned value should be the
copy that you made at the very beginning.

Whether it fixes your original problem is another matter.

Regards,
FCh


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