It think it's clearer with code:
/* API header */
struct pt
{
int x;
int y;
};
extern struct pt *ptcreate(int x, int y);
extern struct pt *ptdestroy(struct pt *ptr);
/* API source file */
struct pt *ptcreate(x, y)
int x;
int y;
{
struct pt *ptr = (struct pt *) malloc(sizeof (struct pt));
if (ptr == (struct pt *) NULL)
{
return (struct pt *) NULL;
}
pt->x = x;
pt->y = y
return ptr;
}
void ptdestroy(struct pt *ptr)
{
if (ptr == (struct pt *) NULL)
{
return;
}
free(ptr);
}
/* program source file */
#include <api.h>
int main()
{
/*
the scope of ptr start here and it takes the return value of
the ptcreate function
*/
struct pt *ptr = create(0, 0);
ptdestroy(ptr);
}