how do you write an implementation for the routine
void delete_bufr( BUFR *p ){
which deallocates all storage associated with the buffer pointed to by p and sets p to a NULL value.
here is the header file for the above function:
thanks
Atif.
/*******************
* circbuf.1.h *
*******************/
/************************************************** **************
* *
* Prototypes for functions operating on buffer. *
* * *
*
* *
* init_bufr(n): *
* allocates buffer, size n; returns pointer to buffer. *
* *
* pushout(buffer,a,b): *
* adds a to buffer; returns true if a overwrites oldest *
* char which is copied to *b; returns false otherwise *
* *
* remchars(buffer,n): *
* removes the n oldest chars from buffer *
* *
* matchkey(buffer,key): *
* returns true if the string key matches the contents of *
* the buffer, STARTING FROM THE OLDEST CHARACTER in buffer*
* *
* pick_char(buffer,k,b): *
* copies kth oldest character in buffer to *b, returning *
* true if successful or false if there was no such char *
* *
* dump_bufr(buffer): *
* for debugging: writes to stderr the current contents of *
* buffer and its idea of how many chars; the next vacant *
* spot and/or oldest character is marked by >>> *
* *
* clr_bufr(buffer): *
* empties, but doesn't destroy buffer *
*
delete_bufr(bufptr): destroys buffer (== *bufptr) sets *bufptr to null
************************************************** **************/
#ifndef BUFR
#define BUFR void *
#endif
BUFR init_bufr(int);
int pushout( BUFR , int, int * );
int remchars( BUFR , int );
int matchkey( BUFR , char * );
int pick_char( BUFR , int, char * );
void dump_bufr(BUFR );
void clr_bufr(BUFR );
void delete_bufr(BUFR *);