Mail Archives: djgpp-workers/1998/09/17/16:53:39
DJ Delorie wrote :
>
> No, I mean I ran patch and it failed. The diff doesn't match the
> sources any more. Could you re-do it against the latest snapshot?
Ah!!
Now I found also, why patch failed. I silently assumed,
that you had already applied the other patch which handles
the check for NULL _before_ the 'BLOCK *b' is initialized.
Now I included this fix also and here is now the patch:
*** src/libc/ansi/stdlib/malloc.c~ Sun Jun 28 22:14:04 1998
--- src/libc/ansi/stdlib/malloc.c Thu Sep 17 22:42:38 1998
***************
*** 326,344 ****
void *
realloc(void *ptr, size_t size)
{
! BLOCK *b = (BLOCK *)((char *)ptr-4);
char *newptr;
int copysize;
if (ptr == 0)
return malloc(size);
! copysize = b->size;
! if (size <= b->size)
{
#if 0
! if (b->size < 2*MIN_SAVE_EXTRA
! || (size >= b->size-512 && size >= b->size/2))
#endif
return ptr;
copysize = size;
--- 326,345 ----
void *
realloc(void *ptr, size_t size)
{
! BLOCK *b;
char *newptr;
int copysize;
if (ptr == 0)
return malloc(size);
! b = (BLOCK *)((char *)ptr-4);
! copysize = b->size & ~1;
! if (size <= copysize)
{
#if 0
! if (copysize < 2*MIN_SAVE_EXTRA
! || (size >= copysize-512 && size >= copysize/2))
#endif
return ptr;
copysize = size;
***************
*** 347,353 ****
newptr = (char *)malloc(size);
#if DEBUG
printf("realloc %d %d/%08x %08x->%08, %d\n",
! size, b->size, b, ptr, newptr, copysize);
#endif
memcpy(newptr, ptr, copysize);
free(ptr);
--- 348,354 ----
newptr = (char *)malloc(size);
#if DEBUG
printf("realloc %d %d/%08x %08x->%08, %d\n",
! size, b->size & ~1, b, ptr, newptr, copysize);
#endif
memcpy(newptr, ptr, copysize);
free(ptr);
- Raw text -