home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume8 / mdcopy / part02 / mdsetbuf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-02  |  504 b   |  29 lines

  1. /*
  2.  * Created 1989 by greg yachuk.  Placed in the public domain.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <malloc.h>
  7.  
  8. #include "mdiskio.h"
  9.  
  10. mdsetbuf(mdp, blen)
  11. MDFILE *mdp;
  12. int    blen;
  13. {
  14.     if (mdp->buffer != NULL)
  15.         return (1);        /* already has a buffer */
  16.  
  17.     if ((mdp->buffer = malloc(blen)) == NULL)
  18.         return (2);        /* not enough memory */
  19.  
  20.     /* calculate the end pointer */
  21.     mdp->bufptr = mdp->buffer + blen;
  22.  
  23.     /* indicate an empty buffer */
  24.     mdp->flags |= _MDEMPTY;
  25.  
  26.     /* indicate that all is well */
  27.     return (0);
  28. }
  29.