home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume4
/
bm1.2
/
MakeDesc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-11-30
|
718b
|
27 lines
#include <stdio.h>
#include "bm.h"
#include "Extern.h"
extern char * malloc();
/* makes a pattern descriptor */
struct PattDesc *MakeDesc(Pattern)
char *Pattern;
{
struct PattDesc *Desc;
Desc = (struct PattDesc *) malloc(sizeof(struct PattDesc));
if (!(Desc->Skip1 = (unsigned short int *)
malloc( sizeof(int) * (MAXCHAR + 1)))){
fprintf(stderr,"bm: can't allocate space\n");
exit(2);
} /* if */
if (!(Desc->Skip2 = (unsigned short int *)
malloc(sizeof(int) * strlen(Pattern)))){
fprintf(stderr,"bm: can't allocate space\n");
exit(2);
} /* if */
Desc->Pattern=Pattern;
Desc->PatLen = strlen(Desc->Pattern);
MakeSkip(Desc->Pattern,Desc->Skip1,
Desc->Skip2,Desc->PatLen);
return(Desc);
} /* main */