Re: Kernel malloc/realloc?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bogdan Bejan (na_at_na.na)
Date: 02/05/04


Date: Thu, 5 Feb 2004 15:12:06 +0200


"Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
news:u7ysgH66DHA.4012@tk2msftngp13.phx.gbl...
> one of the semantics of realloc is that the same pointer as before can be
> returned (i haven't used realloc in such a long time, i can't remember if
> this true 100% of the time or not).

Any for of realocation of a memory buffer can't possible guarantee to return
the same adress, what if you don't have enought linear virtual memory there
to fulfill the request?

So this applayes to maloc or any other function, i think.

> Based on this assumption if you were to
> resize a buffer, you would need to
> 1) make sure any threads that are using the previous buffer have stopped
> using it
> 2) update the field which contains the pointer value so that no one picks
> up the old value and starts using the new one

I really know this.
I just don't know how to acctualy resize a memory buffer in kernel mode.

>
> d
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Please reply to newsgroups only.
>
> "Bogdan Bejan" <na@na.na> wrote in message
> news:ufvFlI36DHA.2952@TK2MSFTNGP09.phx.gbl...
> > I wasn't sure is shuch API exists in kernel, thanx for clearing it.
> >
> > "Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
> > news:uocOjcs6DHA.1556@tk2msftngp13.phx.gbl...
> > > no such API exists. you must be able to update the pointer value
> > atomically
> > > if you need to have a bigger allocation
> >
> > Don't you have to update the pointer with realloc to? Isn't realloc
based
> on
> > GlobalRealloc?Which i suppose works by allocating more hardware pages
and
> > mapping them in a new vitual location, where you have enough virtual
space
> > for the new buffer?
> >
> > >
> > > d
> > >
> > > --
> > > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> > > Please reply to newsgroups only.
> > >
> > > "Bogdan Bejan" <na@na.na> wrote in message
> > > news:euNZM9r6DHA.2764@TK2MSFTNGP09.phx.gbl...
> > > > How can you alocate then realocate a memory buffer in kernel mode
> (W2k+)
> > ?
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Kernel malloc/realloc?
    ... >> one of the semantics of realloc is that the same pointer as before can ... > Any for of realocation of a memory buffer can't possible guarantee to ... > I just don't know how to acctualy resize a memory buffer in kernel mode. ...
    (microsoft.public.development.device.drivers)
  • Re: filters
    ... you go about writing a filter, ... just be put into some buffer. ... * if realloc() fails, it returns a null pointer, and pointers into the ...
    (comp.lang.c)
  • Re: filters
    ... stdin and processes it? ... just be put into some buffer. ... * if realloc() fails, it returns a null pointer, and pointers into the ...
    (comp.lang.c)
  • Re: Kernel malloc/realloc?
    ... one of the semantics of realloc is that the same pointer as before can be ... make sure any threads that are using the previous buffer have stopped ... >> if you need to have a bigger allocation ...
    (microsoft.public.development.device.drivers)
  • Re: malloc realloc and pointers
    ... perticular position in a buffer then on performing a ... realloc() returns the same pointer, in which case ptr is still ... pointer is identical to the old pointer, you're not allowed to use them ...
    (comp.lang.c)