예제 #1
0
파일: slice.c 프로젝트: AndreDing/FFmpeg
/*
 slice lines contains extra bytes for vectorial code thus @size
 is the allocated memory size and @width is the number of pixels
*/
static int alloc_lines(SwsSlice *s, int size, int width)
{
    int i;
    int idx[2] = {3, 2};

    s->should_free_lines = 1;
    s->width = width;

    for (i = 0; i < 2; ++i) {
        int n = s->plane[i].available_lines;
        int j;
        int ii = idx[i];

        av_assert0(n == s->plane[ii].available_lines);
        for (j = 0; j < n; ++j) {
            // chroma plane line U and V are expected to be contiguous in memory
            // by mmx vertical scaler code
            s->plane[i].line[j] = av_malloc(size * 2 + 32);
            if (!s->plane[i].line[j]) {
                free_lines(s);
                return AVERROR(ENOMEM);
            }
            s->plane[ii].line[j] = s->plane[i].line[j] + size + 16;
            if (s->is_ring) {
               s->plane[i].line[j+n] = s->plane[i].line[j];
               s->plane[ii].line[j+n] = s->plane[ii].line[j];
            }
        }
    }

    return 0;
}
예제 #2
0
파일: pfmsetup.c 프로젝트: naps62/CPD_PAPI
/**
 * read_file
 *
 * Read in the command-file. Create an array of strings, with one string
 * for each line in the file. The last entry in the array will be NULL
 * to indicate the end of the file.
 **/
static int read_file(FILE *fp, char ***lines)
{
	char one_line[1024], *str, **strings = NULL;
	int num_lines = 1;
	int i = 0;

	while (1) {
		str = fgets(one_line, 1024, fp);
		if (!str) {
			break;
		}

		if (i == num_lines || !strings) {
			num_lines *= 2;
			strings = realloc(strings, num_lines * sizeof(*strings));
			if (!strings) {
				return ENOMEM;
			}
		}

		strings[i] = strdup(one_line);
		if (!strings[i]) {
			free_lines(strings);
			return ENOMEM;
		}

		i++;
		strings[i] = NULL;
	}

	*lines = strings;
	return 0;
}
예제 #3
0
void seqed_shutdown(Tcl_Interp *interp,
		    SeqedResult *result)
{
    Tcl_CmdInfo info;
    tkSeqed *se;
    char *tmp;

#ifdef DEBUG
    printf("seqed shutdown \n");
#endif

    Tcl_GetCommandInfo(interp, result->seqed_win, &info);
    se = (tkSeqed*)info.clientData;

   if (se->renzDisplayed) {
	free_lines();
	free_r_enzyme(se->r_enzyme, se->num_enzymes);
    }

    /* destroy toplevel seqed window */
    Tcl_VarEval(interp, "winfo toplevel ", result->seqed_win, NULL);
    Tcl_VarEval(interp, "destroy ", Tcl_GetStringResult(interp), NULL);

    tmp = get_default_string(interp, tk_utils_defs, w("RASTER.RESULTS.WIN"));
    if (TCL_OK != Tcl_VarEval(interp, "seq_result_list_update ", 
			      tmp, NULL)){
	verror(ERR_WARN, "seqed shutdown", "%s \n", Tcl_GetStringResult(interp));
    }

    xfree(result);
}
예제 #4
0
void cw_flush(t_col_writer *writer) {
  for (int i = 0; i < writer->_linecount; i++) {
    flush_line(writer, writer->_lines[i]);
  }

  free_lines(writer);
  free(writer->_colwidths);
  writer->_colwidths = NULL;
}
예제 #5
0
파일: slice.c 프로젝트: AndreDing/FFmpeg
static void free_slice(SwsSlice *s)
{
    int i;
    if (s) {
        if (s->should_free_lines)
            free_lines(s);
        for (i = 0; i < 4; ++i) {
            av_freep(&s->plane[i].line);
            s->plane[i].tmp = NULL;
        }
    }
}
예제 #6
0
/*---------------------------------------------------------------------------------------------
 * (function: endSimulation)
 *-------------------------------------------------------------------------------------------*/
void OdinInterface::endSimulation(){
    free_pin_name_list(hold_high);
    free_pin_name_list(hold_low);
    hold_high_index->destroy_free_items(hold_high_index);
    hold_low_index ->destroy_free_items(hold_low_index);

    fflush(out);
    fprintf(modelsim_out, "run %d\n", num_vectors*100);

    printf("\n");


    free_stages(stgs);

    free_lines(output_lines);
    free_lines(input_lines);

    fclose(modelsim_out);
    fclose(in_out);
    if (input_vector_file)
            fclose(in);
    fclose(out);

}
예제 #7
0
파일: pager.c 프로젝트: Distrotech/slang
static int read_file (char *file)
{
   FILE *fp;
   char buf [1024];
   File_Line_Type *line, *last_line;
   unsigned int num_lines;

   if (file == NULL)
     fp = stdin;
   else fp = fopen (file, "r");

   if (fp == NULL) return -1;

   last_line = NULL;
   num_lines = 0;

   while (NULL != fgets (buf, sizeof(buf), fp))
     {
	num_lines++;

	if (NULL == (line = create_line (buf)))
	  {
	     fprintf (stderr, "Out of memory.");
	     free_lines ();
	     return -1;
	  }

	if (last_line == NULL)
	  File_Lines = line;
	else
	  last_line->next = line;

	line->prev = last_line;
	line->next = NULL;

	last_line = line;
     }

   memset ((char *)&Line_Window, 0, sizeof (SLscroll_Window_Type));

   Line_Window.current_line = (SLscroll_Type *) File_Lines;
   Line_Window.lines = (SLscroll_Type *) File_Lines;
   Line_Window.line_num = 1;
   Line_Window.num_lines = num_lines;
   /* Line_Window.border = 3; */

   return 0;
}
예제 #8
0
/*
 * read in hba config file
 */
void load_hba(char *hbapath)
{
	FILE *file;

	POOL_MEMORY_POOL *old_context;
	if (hba_memory_context == NULL)
	{
		hba_memory_context = pool_memory_create(PARSER_BLOCK_SIZE);
		if (hba_memory_context == NULL)
		{
			pool_error("load_hba: pool_memory_create() failed");
			exit(1);
		}
	}
	/* switch memory context */
	old_context = pool_memory;
	pool_memory = hba_memory_context;

	if (hba_lines || hba_line_nums)
		free_lines(&hba_lines, &hba_line_nums);

	file = fopen(hbapath, "r");
	if (!file)
	{
		pool_error("could not open \"%s\". reason: %s",
				   hbapath, strerror(errno));
		exit(1);
	}

	pool_debug("loading \"%s\" for client authentication configuration file",
			   hbapath);

	tokenize_file(hbapath, file, &hba_lines, &hba_line_nums);
	fclose(file);

	hbaFileName = pstrdup(hbapath);

	/* switch old memory context */
	pool_memory = old_context;
}
예제 #9
0
void seqed_shutdown(Tcl_Interp *interp,
                    SeqedResult *result,
                    element *e)
{
    Tcl_CmdInfo info;
    tkSeqed *se;

#ifdef DEBUG
    printf("seqed shutdown \n");
#endif

    Tcl_GetCommandInfo(interp, result->seqed_win, &info);
    se = (tkSeqed*)info.clientData;

    if (se->renzDisplayed) {
        free_lines();
        free_r_enzyme(se->r_enzyme, se->num_enzymes);
    }
    Tcl_VarEval(e->c->interp, "result_list_update ", e->c->win, NULL);

    xfree(result);
}
예제 #10
0
파일: exit.c 프로젝트: fdeage/asm
int			exit_asm(t_file *file)
{
	int	leaks;

	ft_putstr_color("TRY EXITING... ", COL_GREEN);
	free_lines(file);
	close(file->fd_s);
	close(file->fd_cor);
	if (file->name_s)
		free(file->name_s);
	if (file->name_cor)
		free(file->name_cor);
	leaks = file->options;
	free(file);
	ft_putstr_color("SUCCESSFUL EXIT!\n", COL_GREEN);
	if ((leaks & T_OPTION_LEAKS) == T_OPTION_LEAKS)
	{
		ft_putstr_color("Leaks mode activated...\n", COL_YELLOW);
		while (42)
			usleep(10000);
	}
	return (EXIT_SUCCESS);
}
예제 #11
0
void    scr_go( void )
{
    condcode        cc;
    getnum_block    gn;
    labelcb     *   golb;
    int             k;
    char            linestr[MAX_L_AS_STR];

    input_cbs->if_cb->if_level = 0;     // .go terminates
    ProcFlags.keep_ifstate = false;     // ... all .if controls

    garginit();

    cc = getarg();
    if( cc != pos ) {
        scan_err = true;
        err_count++;
        g_err( err_missing_name, "" );
        if( input_cbs->fmflags & II_tag_mac ) {
            utoa( input_cbs->s.m->lineno, linestr, 10 );
            g_info( inf_mac_line, linestr, input_cbs->s.m->mac->name );
        } else {
            utoa( input_cbs->s.f->lineno, linestr, 10 );
            g_info( inf_file_line, linestr, input_cbs->s.f->filename );
        }
        show_include_stack();
        return;
    }

    gn.argstart      = tok_start;
    gn.argstop       = scan_stop;
    gn.ignore_blanks = 0;

    cc = getnum( &gn );             // try numeric expression evaluation
    if( cc == pos  || cc  == neg) {     // numeric linenumber
        gotarget[0] = '\0';             // no target label name
        if( gn.num_sign == ' '  ) {     // absolute number
            gotargetno = gn.result;
        } else {
            if( input_cbs->fmflags & II_tag_mac ) {
                gotargetno = input_cbs->s.m->lineno;
            } else {
                gotargetno = input_cbs->s.f->lineno;
            }
            gotargetno += gn.result;    // relative target line number
        }

        if( gotargetno < 1 ) {
            scan_err = true;
            err_count++;
            g_err( err_label_zero );
            if( input_cbs->fmflags & II_tag_mac ) {
                utoa( input_cbs->s.m->lineno, linestr, 10 );
                g_info( inf_mac_line, linestr, input_cbs->s.m->mac->name );
            } else {
                utoa( input_cbs->s.f->lineno, linestr, 10 );
                g_info( inf_file_line, linestr, input_cbs->s.f->filename );
            }
            show_include_stack();
            return;
        }
        if( input_cbs->fmflags & II_tag_mac ) {
            if( gotargetno <= input_cbs->s.m->lineno ) {
                input_cbs->s.m->lineno = 0; // restart from beginning
                input_cbs->s.m->macline = input_cbs->s.m->mac->macline;
            }
        }
    } else {                            // no numeric target label

        gotargetno = 0;                 // no target lineno known
        if( arg_flen >  MAC_NAME_LENGTH ) {
            err_count++;
            g_err( err_sym_long, tok_start );
            if( input_cbs->fmflags & II_tag_mac ) {
                utoa( input_cbs->s.m->lineno, linestr, 10 );
                g_info( inf_mac_line, linestr, input_cbs->s.m->mac->name );
            } else {
                utoa( input_cbs->s.f->lineno, linestr, 10 );
                g_info( inf_file_line, linestr, input_cbs->s.f->filename );
            }
            show_include_stack();
            arg_flen = MAC_NAME_LENGTH;
        }

        for( k = 0; k < MAC_NAME_LENGTH; k++ ) {// copy to work
            gotarget[k] = *tok_start++;
        }
        gotarget[k] = '\0';

        golb = find_label( gotarget );
        if( golb != NULL ) {            // label already known
            gotargetno = golb->lineno;

            if( input_cbs->fmflags & II_tag_mac ) {
                if( golb->lineno <= input_cbs->s.m->lineno ) {
                    input_cbs->s.m->lineno = 0; // restart from beginning
                    input_cbs->s.m->macline = input_cbs->s.m->mac->macline;
                }
            } else {
                if( golb->lineno <= input_cbs->s.f->lineno ) {
                    fsetpos( input_cbs->s.f->fp, &golb->pos );
                    input_cbs->s.f->lineno = golb->lineno - 1;// position file
                }
            }
        }
    }
    free_lines( input_cbs->hidden_head );   // delete split line
    input_cbs->hidden_head = NULL;
    input_cbs->hidden_tail = NULL;
    ProcFlags.goto_active = true;       // special goto processing
    scan_restart = scan_stop + 1;

}
예제 #12
0
void free_ast(struct preset *p)
{
	free_lines(p->lines);
	free(p);
}
예제 #13
0
파일: pfmsetup.c 프로젝트: naps62/CPD_PAPI
int main(int argc, char **argv)
{
	FILE *fp;
	struct command *cmd;
	char *filename;
	char **lines;
	char *tokens[MAX_TOKENS + 1] = {NULL};
	int num_tokens;
	int rc, i;

	if (argc < 2 ||
	    !strcmp(argv[1], "-?") ||
	    !strcasecmp(argv[1], "-h") ||
	    !strcasecmp(argv[1], "--help")) {
		print_help(argv[0]);
		return EINVAL;
	}
	filename = argv[1];

	/* Open the command file and read the entire
	 * contents into the 'lines' array.
	 */
	fp = fopen(filename, "r");
	if (!fp) {
		rc = errno;
		LOG_ERROR("Can't open file %s.\n", filename);
		return rc;
	}

	rc = read_file(fp, &lines);
	if (rc) {
		LOG_ERROR("Can't read file %s.\n", filename);
		return rc;
	}

	if (!lines) {
		LOG_ERROR("File %s is empty.\n", filename);
		rc = EINVAL;
		return rc;
	}

	/* Process each line from the command file. */
	for (i = 0; lines[i]; i++) {
		tokenize(lines[i], &num_tokens, tokens);
		if (!num_tokens) {
			/* Skip empty lines. */
			continue;
		}

		if (tokens[0][0] == '#') {
			/* Skip lines that start with '#'. */
			continue;
		}

		/* The first token specifies the command to run. Find this
		 * command in the array, check that we have enough arguments,
		 * and then run the command. If anything goes wrong with a
		 * command, we skip all remaining commands.
		 */
		cmd = find_command(tokens[0]);
		if (!cmd) {
			LOG_ERROR("Invalid command '%s' (line %d).\n",
				  tokens[0], i+1);
			rc = EINVAL;
			break;
		}

		if (num_tokens - 1 < cmd->min_args) {
			LOG_ERROR("Incorrect number of arguments for command "
				  "\'%s\' (line %d)", tokens[0], i+1);
			USAGE("%s %s", cmd->full_name, cmd->help);
			rc = EINVAL;
			break;
		}

		rc = cmd->fn(num_tokens, tokens);
		if (rc) {
			LOG_ERROR("command '%s' (line %d) returned an error: "
				  "%d.", tokens[0], i+1, rc);
			break;
		}
	}

	free_lines(lines);
	return rc;
}