[Kst] kdeextragear-2/kst/kst [POSSIBLY UNSAFE]

George Staikos staikos at kde.org
Tue Jul 13 23:39:40 CEST 2004


On Tuesday 13 July 2004 17:37, Barth Netterfield wrote:
> OK.  You are doing this.  I'll drop my version.

  Ooops.  Sorry, I didn't realise you were working on it.  Anyhow, it's not 
exactly done.  I think I just did two of the three hard parts - searching out 
mallocs/reallocs and making sure everything is consistent, and integrating 
the native code.  The error recovery is still needed and I marked it with 
FIXMEs.  We also need to look at the "algorithm" to determine if that's what 
you really want.  Presently it just checks the free+buffers+cache to make 
sure that they can hold the memory needed.  This will still lead to swapping 
in at least some cases, and it's not exactly "smart".

> > +void *KST::realloc(void *ptr, size_t size) {
> > +#ifdef HAVE_LINUX
> > +  meminfo();
> > +  unsigned long bFree = S(kb_main_free + kb_main_buffers +
> > kb_main_cached); +  if (size > bFree) {
> > +    qDebug("Tried to allocate too much memory! (Wanted %u, had %lu)",
> > size, bFree); +    return 0L;
> > +  }
> > +#endif
> > +  return ::realloc(ptr, size);
> > +}

-- 
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/



More information about the Kst mailing list