www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/08/17:04:46

Message-Id: <199905082104.VAA49736@out4.ibm.net>
From: "Mark E." <snowball3 AT bigfoot DOT com>
To: djgpp-workers AT delorie DOT com
Date: Sat, 8 May 1999 17:04:50 -0400
MIME-Version: 1.0
Subject: warnings in malloc.c
X-mailer: Pegasus Mail for Win32 (v3.01d)
Reply-To: djgpp-workers AT delorie DOT com

When compiling malloc.c with -W, gcc reports warnings for 
comparisons between unsigned and signed in several places. This 
occurs because malloc and realloc take a size_t while BLOCK uses an 
int. The fix is trivial but hardly critical:

*** src/libc/ansi/stdlib/malloc.c.orig	Mon Apr 19 23:33:08 1999
--- src/libc/ansi/stdlib/malloc.c	Sat May  8 16:50:50 1999
***************
*** 6,12 ****
  #include <unistd.h>
  
  typedef struct BLOCK {
!   int size;
    struct BLOCK *next;
    int bucket;
  } BLOCK;
--- 6,12 ----
  #include <unistd.h>
  
  typedef struct BLOCK {
!   size_t size;
    struct BLOCK *next;
    int bucket;
  } BLOCK;
*************** realloc(void *ptr, size_t size)
*** 329,335 ****
  {
    BLOCK *b;
    char *newptr;
!   int copysize;
  
    if (ptr == 0)
      return malloc(size);
--- 329,335 ----
  {
    BLOCK *b;
    char *newptr;
!   size_t copysize;
  
    if (ptr == 0)
      return malloc(size);

--- 
Mark Elbrecht, snowball3 AT bigfoot DOT com
http://snowball.frogspace.net/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019