I am using a pgcc compiler to compile the following piece of code. I keep getting this warning and I am not sure what is wrong with it. Here is the code, followed by the warning:
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#ifdef _CRAY
int MEMALLOC (nextptr, size)
#else
#ifdef POST_UNDERSCORE
int memalloc_ (nextptr, size)
#else
int memalloc (nextptr, size)
#endif
#endif
int *size;
int *nextptr;
{
void *ptr;
if (*nextptr == NULL) {
if ((ptr = (void *) malloc (*size)) == NULL) {
return(-1);
}
}
else {
if ((ptr = (void *) realloc (*nextptr, *size)) == NULL) {
return(-1);
}
}
*nextptr = (int) ptr;
return (0);
These are the following errors that I get
memalloc.c", line 19: warning: operand types are incompatible ("int" and "void
*")
if (*nextptr == NULL) {
^
"memalloc.c", line 25: warning: argument of type "int" is incompatible with
parameter of type "void *"
if ((ptr = (void *) realloc (*nextptr, *size)) == NULL) {
^
"memalloc.c", line 29: warning: conversion from pointer to smaller integer
*nextptr = (int) ptr;
What am I doing wrong?