FreeBSD/lib/libpmc/pmclog.c
/*
 * Allocate and initialize parser state.
 */
Allocate and initialize parser state.
Allocate and initialize parser state .
void *
pmclog_open(int fd)
{
	struct pmclog_parse_state *ps;
	if ((ps = (struct pmclog_parse_state *) malloc(sizeof(*ps))) == NULL)
		return NULL;
	ps->ps_state = PL_STATE_NEW_RECORD;
	ps->ps_arch = -1;
	ps->ps_initialized = 0;
	ps->ps_count = 0;
	ps->ps_offset = (off_t) 0;
	bzero(&ps->ps_saved, sizeof(ps->ps_saved));
	ps->ps_svcount = 0;
	ps->ps_fd    = fd;
	ps->ps_data  = NULL;
	ps->ps_buffer = NULL;
	ps->ps_len   = 0;
	if (ps->ps_fd != PMCLOG_FD_NONE) {
		if ((ps->ps_buffer = malloc(PMCLOG_BUFFER_SIZE)) == NULL) {
			free(ps);
			return NULL;
		}
	}
	return ps;
}
void * pmclog_open ( int fd ) { struct pmclog_parse_state * ps ; if ( ( ps = ( struct pmclog_parse_state * ) malloc ( sizeof ( * ps ) ) ) == NULL ) return NULL ; ps -> ps_state = PL_STATE_NEW_RECORD ; ps -> ps_arch = -1 ; ps -> ps_initialized = 0 ; ps -> ps_count = 0 ; ps -> ps_offset = ( off_t ) 0 ; bzero ( & ps -> ps_saved , sizeof ( ps -> ps_saved ) ) ; ps -> ps_svcount = 0 ; ps -> ps_fd = fd ; ps -> ps_data = NULL ; ps -> ps_buffer = NULL ; ps -> ps_len = 0 ; if ( ps -> ps_fd != PMCLOG_FD_NONE ) { if ( ( ps -> ps_buffer = malloc ( PMCLOG_BUFFER_SIZE ) ) == NULL ) { free ( ps ) ; return NULL ; } } return ps ; }
Allocate and initialize parser state.
Allocate and initialize parser state .
/* allocate space for a work area */