* introduced NULL in the headers
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 2 Feb 2003 20:36:49 +0000 (20:36 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 2 Feb 2003 20:36:49 +0000 (20:36 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2203 4a8a32a2-be11-0410-ad9d-d568d2c75423

20 files changed:
ChangeLog
device/include/malloc.h
device/include/stdlib.h
device/include/string.h
device/lib/_memcpy.c
device/lib/_strcat.c
device/lib/_strchr.c
device/lib/_strcmp.c
device/lib/_strcpy.c
device/lib/_strcspn.c
device/lib/_strlen.c
device/lib/_strncat.c
device/lib/_strncmp.c
device/lib/_strncpy.c
device/lib/_strpbrk.c
device/lib/_strrchr.c
device/lib/_strspn.c
device/lib/_strstr.c
device/lib/_strtok.c
device/lib/malloc.c

index 32313a470d2818539c369d139616fde70690f43f..171008c080b24fc483b648d73e442e2b6e7ca4e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2003-02-02  Bernhard Held <bernhard@bernhardheld.de>
+
+       * device/include/malloc.h: introduced NULL
+       * device/include/string.h: introduced NULL
+       * device/include/stdlib.h: introduced NULL
+       * device/lib/_memcpy.c: removed NULL
+       * device/lib/_strcat.c: removed NULL
+       * device/lib/_strchr.c: removed NULL
+       * device/lib/_strcmp.c: removed NULL
+       * device/lib/_strcpy.c: removed NULL
+       * device/lib/_strcspn.c: removed NULL
+       * device/lib/_strlen.c: removed NULL
+       * device/lib/_strncat.c: removed NULL
+       * device/lib/_strncmp.c: removed NULL
+       * device/lib/_strncpy.c: removed NULL
+       * device/lib/_strpbrk.c: removed NULL
+       * device/lib/_strrchr.c: removed NULL
+       * device/lib/_strspn.c: removed NULL
+       * device/lib/_strstr.c: removed NULL
+       * device/lib/_strtok.c: removed NULL
+       * device/lib/malloc.c: removed NULL, include own header
+       * device/lib/_strspn.c: removed NULL
+       * device/lib/_strspn.c: removed NULL
+       * device/lib/_strspn.c: removed NULL
+
+
 2003-02-02    <johan@balder>
 
        * src/mcs51/ralloc.c (packForPush): fixed bug #631653, maybe other ports need this too? At least now some new alerts in SDCCBBlock.c and SDCCicode.c gives an early warning
@@ -46,7 +72,7 @@
 2003-01-28  Bernhard Held <bernhard@bernhardheld.de>
 
        * src/ds390/gen.c: fix deps by replacing <common.h> with "common.h"
-       * src/SDCC.lex: rename P_OVERLAY to P_OVERLAY_ for cross-gcc 3.2 MINGW32 
+       * src/SDCC.lex: rename P_OVERLAY to P_OVERLAY_ for cross-gcc 3.2 MINGW32
 
 2003-01-27    <johan@balder>
 
index 05055bbf009b640c28df6c9de214173b769e4643..261e56c1fb490da12bcb5f694a48ef5fde4b2cec 100644 (file)
@@ -7,25 +7,29 @@
    under the terms of the GNU General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 /* malloc.h */
 #ifndef __SDCC51_MALLOC_H
 #define __SDCC51_MALLOC_H
 #include <sdcc-lib.h>
 
+#ifndef NULL
+# define NULL (void *)0
+#endif
+
 #if _SDCC_MALLOC_TYPE_MLH
 void *malloc (unsigned int);
 void free(void *p);
@@ -47,7 +51,7 @@ MEMHEADER
 
 extern void init_dynamic_memory(MEMHEADER xdata *  , unsigned int ) reentrant;
 extern void xdata * malloc (unsigned int ) reentrant;
-extern void free (void * xdata p) reentrant;
+extern void free (void xdata * p) reentrant;
 
 #else
 
index 828c41c4dc24cc8331a5ad3aae10b32fea57acf7..17043cd22b6269ff8552d9e3b735e0984672e886 100644 (file)
@@ -1,30 +1,34 @@
 /*-------------------------------------------------------------------------
   stdlib.h - ANSI functions forward declarations
+
              Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1998)
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
 #ifndef __SDC51_STDLIB_H
 #define __SDC51_STDLIB_H 1
 
+#ifndef
+# define NULL (void *)0
+#endif
+
 extern int atoi (char *);
 extern long atol (char *);
 
@@ -34,9 +38,3 @@ extern void _itoa(unsigned int, char*, unsigned char);
 extern void _ultoa(unsigned long, char*, unsigned char);
 extern void _ltoa(unsigned long, char*, unsigned char);
 #endif
-
-
-
-
-
-
index c220664c69a38c48e5e78c68d2926b5fef0b95a9..5909896e6b394b0d2b74711eb1161571d7eb681b 100644 (file)
 #define reentrant
 #endif
 
+#ifndef NULL
+# define NULL (void *)0
+#endif
+
 #define memmove memcpy
 
 #ifdef SDCC_STACK_AUTO
index aebbbb9cc39d16949d9b588b9820d8446d5b4c6d..38d01ad8047d790ea0aa48a75e1aef4224330e73 100644 (file)
@@ -26,8 +26,6 @@
 
 #if !_SDCC_PORT_PROVIDES_MEMCPY
 
-#define NULL (void *)0
-
 void * memcpy (
        void * dst,
        void * src,
index f4cb963140a8f80e50cb3a4571a7c8c7504e3c9c..f1c4b0ecb9d8f064b36008708bba561505bcfca1 100644 (file)
@@ -7,22 +7,22 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
+
 char * strcat (
         char * dst,
         char * src
index ce9c09083aad2624b5ebe9f0fcd66d2a018e7cd8..8f4e4cbbae8cdf95f2c9fb7b16a7bbc1033f511e 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
 
 char * strchr (
        char * string,
index 47681961d034461f66721897ae8346e0296658be..eeceb8bae5bf9132a904bab671774677fef4ab7a 100644 (file)
@@ -7,27 +7,25 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
+#include "string.h"
 #include <sdcc-lib.h>
 
 #if !_SDCC_PORT_PROVIDES_STRCMP
 
-#define NULL (void *)0
-
 int strcmp (
        char * asrc,
        char * adst
index 5e7c1cdb9fc9ce39d0bc93d8a3ed957b7999e70b..1ee5052e2fd34a70cc0b16cfafd50c659a09f7ba 100644 (file)
@@ -7,27 +7,25 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
+#include "string.h"
 #include <sdcc-lib.h>
 
 #if !_SDCC_PORT_PROVIDES_STRCPY
 
-#define NULL (void *)0
-
 char * strcpy (
        char * d, 
        char * s) 
index b011e1b8db074a0325ff046b9391b22b05c1e9a1..0beaf7526d78a12da59cf39645ff0fd553a59397 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
 
 int strcspn ( 
        char * string ,
index d9c546cc5435fa6daf2428e52ae79cb85732706d..6d0e9acdaba288f7a8725580d0aa540f88d0ce9a 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
 
 int strlen ( char * str ) 
 {
index ec28bf44954c77e3f2d11cf04e928cdc55b85fe3..9aae0ff2446cecfdf389136481ac42fce8c25dad 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
 
 char * strncat (
        char * front,
index 2b7e99040b3d191928fcafbe6359da874e9de787..c55b5fa600abdf53f9db2d43d1996c60d7fd2514 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
 
 int strncmp (
        char * first,
index 1fe12f6f9998f7e37f8ce43ec3e6735aef7eab62..19b8a1a0bde002a76cff91b1ea461e0a32a7e90a 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
 
 char *strncpy (
        char * d,
index 76e2a08c1db0a879f93a4c081eedc92430eddcb2..cddd369faa55a55bebf8fb64a6fe6bfac3428968 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 #include <string.h>
-#define NULL (void *)0
 
 char * strpbrk ( 
        char * string ,
index 3ed636e42259e6acdb3b5a66813688343cf3f865..5d6a6deb3dc0a345bf11d82de356b8eb8839c6c5 100644 (file)
@@ -7,22 +7,21 @@
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library General Public License
    along with this program; if not, write to the Free Software
    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   
+
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
-#include "string.h" 
-#define NULL (void *)0
+#include "string.h"
 
 char * strrchr (
        char * string,
index 377aeed983354f826d6b9d2da16c914f013e99bc..fae51a6f7230cb87b5e023ef91448e3d146526d3 100644 (file)
@@ -22,7 +22,6 @@
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
 #include "string.h" 
-#define NULL (void *)0
 
 int strspn (
        char * string,
index 13d36e5c24531c8b0376c58af429f2f59f28e6e1..272ad16453a25d3e0499c862dd6eac024ef7effb 100644 (file)
@@ -22,7 +22,6 @@
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
 #include "string.h" 
-#define NULL (void *)0
 
 char * strstr (
        char * str1,
index 7f00370a78cd31b4b149cc2cec83fcc2c03f7ad1..82a09c3aaeeec2e3afe0be347d884721eebd9fa1 100644 (file)
@@ -22,7 +22,6 @@
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
 #include "string.h" 
-#define NULL (void *)0
 
 #if defined(SDCC_MODEL_LARGE) || defined (SDCC_MODEL_FLAT24)
 #pragma NOINDUCTION
index 22f813c59a9b4b92effc54013f24e9d14356a992..00439285906a51957f92bb4f4851a88f8cc5da80 100644 (file)
@@ -1,7 +1,7 @@
 #include <sdcc-lib.h>
+#include <malloc.h>
 
 #if _SDCC_MALLOC_TYPE_MLH
-#include <malloc.h>
 
 typedef struct _MEMHEADER MEMHEADER;
 
@@ -14,7 +14,6 @@ struct _MEMHEADER
 };
 
 #define HEADER_SIZE (sizeof(MEMHEADER)-sizeof(char))
-#define NULL        0
 
 /* These veriables are defined through the crt0 functions. */
 /* Base of this variable is the first byte of the heap. */
@@ -22,7 +21,7 @@ extern MEMHEADER _sdcc_heap_start;
 /* Address of this variable is the last byte of the heap. */
 extern char _sdcc_heap_end;
 
-void 
+void
 _sdcc_heap_init(void)
 {
   MEMHEADER *pbase = &_sdcc_heap_start;
@@ -91,7 +90,7 @@ malloc (unsigned int size)
     }
 }
 
-void 
+void
 free (void *p)
 {
   MEMHEADER *prev_header, *pthis;
@@ -103,12 +102,12 @@ free (void *p)
         {
           prev_header = pthis->prev;
           prev_header->next = pthis->next;
-          if (pthis->next)  
+          if (pthis->next)
             {
               pthis->next->prev = prev_header;
             }
         }
-      else 
+      else
         {
           pthis->len = 0; //For the first header
         }
@@ -140,8 +139,6 @@ free (void *p)
             };
 
             #define HEADER_SIZE (sizeof(MEMHEADER)-1)
-            #define NULL        (void xdata * ) 0
-
 
             //Static here means: can be accessed from this module only
             static MEMHEADER xdata * FIRST_MEMORY_HEADER_PTR;
@@ -175,8 +172,8 @@ free (void *p)
               FIRST_MEMORY_HEADER_PTR = array;
               //Reserve a mem for last header
               array->next = (MEMHEADER xdata * )(((char xdata * ) array) + size - HEADER_SIZE);
-              array->next->next = NULL; //And mark it as last
-              array->prev       = NULL; //and mark first as first
+              array->next->next = (void xdata * ) NULL; //And mark it as last
+              array->prev       = (void xdata * ) NULL; //and mark first as first
               array->len        = 0;    //Empty and ready.
             }
 
@@ -185,7 +182,7 @@ free (void *p)
               register MEMHEADER xdata * current_header;
               register MEMHEADER xdata * new_header;
 
-              if (size>(0xFFFF-HEADER_SIZE)) return NULL; //To prevent overflow in next line
+              if (size>(0xFFFF-HEADER_SIZE)) return (void xdata *) NULL; //To prevent overflow in next line
               size += HEADER_SIZE; //We need a memory for header too
               current_header = FIRST_MEMORY_HEADER_PTR;
               while (1)
@@ -202,7 +199,7 @@ free (void *p)
                      ((unsigned int)current_header) -
                      current_header->len) >= size) break; //if spare is more than need
                 current_header = current_header->next;    //else try next             
-                if (!current_header->next)  return NULL;  //if end_of_list reached    
+                if (!current_header->next)  return (void xdata *) NULL;  //if end_of_list reached
               }
               if (!current_header->len)
               { //This code works only for first_header in the list and only
@@ -218,21 +215,21 @@ free (void *p)
               return ((xdata *)&(new_header->mem));
             }
 
-            void free (MEMHEADER xdata * p)
+            void free (void xdata * p)
             {
               register MEMHEADER xdata * prev_header;
               if ( p ) //For allocated pointers only!
               {
                   p = (MEMHEADER xdata * )((char xdata *)  p - HEADER_SIZE); //to start of header
-                  if ( p->prev ) // For the regular header
+                  if ( ((MEMHEADER xdata * ) p)->prev ) // For the regular header
                   {
-                    prev_header = p->prev;
-                    prev_header->next = p->next;
-                    if (p->next)  p->next->prev = prev_header;
+                    prev_header = ((MEMHEADER xdata * ) p)->prev;
+                    prev_header->next = ((MEMHEADER xdata * ) p)->next;
+                    if (((MEMHEADER xdata * ) p)->next)
+                      ((MEMHEADER xdata * ) p)->next->prev = prev_header;
                   }
-                  else p->len = 0; //For the first header
+                  else ((MEMHEADER xdata * ) p)->len = 0; //For the first header
               }
             }
             //END OF MODULE
-
 #endif