Re: More questions on realloc - Thanks




Skarmander wrote:
> David Resnick wrote:
> > James S. Singleton wrote:
> >> Thanks everybody for your replies. I gather that:
> >> b) Implementing realloc(ptr, size) using malloc(), memcpy() and free()
> >> alone, without knowing the size of the memory region pointed to by ptr, is
> >> just not possible.
> >
> > Sure it is possible. Just inefficient. You can malloc a new
> > space, free the old (if malloc succeeds), and copy on all calls
> > to realloc. What you lose is the ability to reuse the existing space
> > in cases where the new size is <= the old, or in cases where there
> > is additional free space after the current block. Which is likely a
> > less than optimal way to do things, but could be good enough.
> >
> How do you copy memory if you don't know the size of the old region? There
> is no way to implement realloc(ptr, size) as a separate function, without
> access to the internal memory management structures. If you think otherwise,
> please supply the code. I have a feeling you're talking about something else
> entirely, but it's unclear what.

You are being charitable assuming I'm talking about something else,
I was just wrong.

-David

.



Relevant Pages

  • Re: Too Much Files
    ... only 38% of free space that is 3.5-4GB of free space. ... DivX and few small applications. ... What is the best Possibility to Clean ... I have 256 Physical memory and 288 Virtual Memory. ...
    (microsoft.public.windowsxp.general)
  • Re: memory problems on windows xp
    ... Memory has nothing to do with a hard drive. ... Hard drives are where you store files on your machine. ... Windows built in defrag needs 15% free space on the hard drive in order ... For more information about Disk Cleanup, ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Programs do not open eventhough installed correctly
    ... Total memory is 37.2 GB and free space is 12 GB... ... I double click on the icon, ... So if you double click on My Computer how much free space is shown on C? ... and office program left a very small amount of memory available). ...
    (microsoft.public.office.misc)
  • Re: adding memory question
    ... performance increase from the memory upgrade. ... free space is not very much for windows and possibly part of your overall ... If I need more memory AND more hard drive, that might really be the time ... think that your money would be far better spent on a hard disk ...
    (alt.sys.pc-clone.dell)
  • RE: Allocate Memory
    ... Under the Virtual Memory the page files size is set to - custom size ... You can check the free space in "My Computer" by right-clicking the drive ... your Publisher Doc is stored on and selecting "Properties". ... If you have at least 15% free space, you can try defragmenting the drive: ...
    (microsoft.public.windowsxp.general)