Skip to content

Commit

Permalink
Use void* for malloc/calloc/realloc/free in sys/libc
Browse files Browse the repository at this point in the history
  • Loading branch information
olebole committed Apr 8, 2024
1 parent c1eecbf commit 792ecce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sys/libc/calloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/* CALLOC -- Allocate memory for NELEM elements of size ELSIZE bytes per
** element. The space is initialized to all zeros.
*/
char *
void *
calloc (
unsigned int nelems,
unsigned int elsize
Expand Down
2 changes: 1 addition & 1 deletion sys/libc/free.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
void
free (
char *buf
void *buf
)
{
XINT x_ptr, x_dtype = TY_CHAR;
Expand Down
4 changes: 2 additions & 2 deletions sys/libc/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/* MALLOC -- Allocate an uninitialized block of memory at least nbytes in size.
*/
char *
void *
malloc (
unsigned nbytes
)
Expand All @@ -20,5 +20,5 @@ malloc (
iferr (MALLOC (&x_ptr, &x_nchars, &x_dtype))
return (NULL);
else
return ((char *)&Memc[x_ptr]);
return ((void *)&Memc[x_ptr]);
}
6 changes: 3 additions & 3 deletions sys/libc/realloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
** allocated buffer. If necessary the buffer is moved, preserving any
** data in the buffer.
*/
char *
void *
realloc (
char *buf,
void *buf,
unsigned newsize
)
{
Expand All @@ -24,5 +24,5 @@ realloc (
iferr (REALLOC (&x_ptr, &x_nchars, &x_dtype))
return (NULL);
else
return ((char *)&Memc[x_ptr]);
return ((void *)&Memc[x_ptr]);
}
8 changes: 4 additions & 4 deletions unix/hlib/libc/iraf_libc.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ extern char *c_cnvtime (long clktime, char *outstr, int maxch);
extern char *c_getuid (char *outstr, int maxch);
extern char *c_salloc (unsigned nbytes);
extern char *c_strpak (short *sppstr, char *cstr, int maxch);
extern char *calloc (unsigned int nelems, unsigned int elsize);
extern void *calloc (unsigned int nelems, unsigned int elsize);
extern char *envget (char *var);
extern char *fgets (char *buf, int maxch, struct _iobuf *fp);
extern char *gets (char *buf);
extern char *malloc (unsigned nbytes);
extern void *malloc (unsigned nbytes);
extern char *mktemp (char *template);
extern char *freadline (char *prompt);
extern char *realloc (char *buf, unsigned newsize);
extern void *realloc (void *buf, unsigned newsize);
extern char *sprintf (char *str, char *format, ...);

extern double atof (char *str);
Expand Down Expand Up @@ -285,7 +285,7 @@ extern void c_xwhen (int exception, funcptr_t new_handler, funcptr_t *old_handle
extern void eprintf (char *format, ...);
extern void fprintf (struct _iobuf *fp, char *format, ...);
extern void fputs (char *str, struct _iobuf *fp);
extern void free (char *buf);
extern void free (void *buf);
extern void perror (char *prefix);
extern void printf (char *format, ...);
extern void setbuf (struct _iobuf *fp, char *buf);
Expand Down

0 comments on commit 792ecce

Please sign in to comment.