• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FREE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FREE函数的典型用法代码示例。如果您正苦于以下问题:C++ FREE函数的具体用法?C++ FREE怎么用?C++ FREE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FREE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: hfs_format


//.........这里部分代码省略.........
      hfsfile bbfile;
      ExtDescriptor extent;
      ExtDataRec *extrec;
      ExtKeyRec key;
      byte record[HFS_MAX_EXTRECLEN];
      unsigned int reclen;

      f_init(&bbfile, &vol, HFS_CNID_BADALLOC, "bad blocks");

      qsort(badalloc, nbadblocks, sizeof(*badalloc),
	    (int (*)(const void *, const void *)) compare);

      for (i = 0; i < nbadblocks; ++i)
	{
	  if (i == 0 || badalloc[i] != extent.xdrStABN)
	    {
	      extent.xdrStABN    = badalloc[i];
	      extent.xdrNumABlks = 1;

	      if (extent.xdrStABN < vol.mdb.drNmAlBlks &&
		  f_addextent(&bbfile, &extent) == -1)
		goto fail;
	    }
	}

      /* flush local extents into extents overflow file */

      f_getptrs(&bbfile, &extrec, 0, 0);

      r_makeextkey(&key, bbfile.fork, bbfile.cat.u.fil.filFlNum, 0);
      r_packextrec(&key, extrec, record, &reclen);

      if (bt_insert(&vol.ext, record, reclen) == -1)
	goto fail;
    }

  vol.flags |= HFS_VOL_MOUNTED;

  /* create root directory */

  if (v_mkdir(&vol, HFS_CNID_ROOTPAR, vname) == -1)
    goto fail;

  vol.mdb.drNxtCNID = 16;  /* first CNID not reserved by Apple */

  /* write boot blocks */

  if (m_zerobb(&vol) == -1)
    goto fail;

  /* zero other unused space, if requested */

  if (vol.flags & HFS_OPT_ZERO)
    {
      block b;
      unsigned long bnum;

      memset(&b, 0, sizeof(b));

      /* between MDB and VBM (never) */

      for (bnum = 3; bnum < vol.mdb.drVBMSt; ++bnum)
	b_writelb(&vol, bnum, &b);

      /* between VBM and first allocation block (sometimes if HFS_OPT_2048) */

      for (bnum = vol.mdb.drVBMSt + vol.vbmsz; bnum < vol.mdb.drAlBlSt; ++bnum)
	b_writelb(&vol, bnum, &b);

      /* between last allocation block and alternate MDB (sometimes) */

      for (bnum = vol.mdb.drAlBlSt + vol.mdb.drNmAlBlks * vol.lpa;
	   bnum < vol.vlen - 2; ++bnum)
	b_writelb(&vol, bnum, &b);

      /* final block (always) */

      b_writelb(&vol, vol.vlen - 1, &b);
    }
	
  /* write boot blocks */
  b_writelb(&vol, 0, (block*)bootblocks);
  b_writelb(&vol, 1, (block*)&bootblocks[HFS_BLOCKSZ]);
  
  /* flush remaining state and close volume */

  if (v_close(&vol) == -1)
    goto fail;

  FREE(badalloc);

  return 0;

fail:
  v_close(&vol);

  FREE(badalloc);

  return -1;
}
开发者ID:andyvand,项目名称:fusehfs,代码行数:101,代码来源:hfs.c


示例2: drawallbuttons

void drawallbuttons(struct w_window *w) {
    static struct w_b_choose modebutton, modifybutton, pigfile;
    static struct w_b_press movebutton[6], pogfile;
    struct w_button *b1, *b2, *b3;
    struct ws_bitmap *bm;
    int i, j, k, bxsize, bysize, y;
    char **pignames;


    modifybutton.num_options = tt_number;
    modifybutton.options = (const char **)init.bnames;
    modifybutton.selected = view.currmode;
    modifybutton.select_lroutine = modifybutton.select_rroutine =
                                       b_changemode;
    modebutton.num_options = mt_number;
    modebutton.options = movemodes;
    modebutton.selected = view.movemode;
    modebutton.select_lroutine = modebutton.select_rroutine =
                                     b_changemovemode;

    if (init.d_ver >= d2_10_reg) {
        pignames = ws_getallfilenames(init.pigpaths[init.d_ver], "pig",
                                      &pigfile.num_options);
        checkmem( pigfile.options =
                     MALLOC(sizeof(char *) * pigfile.num_options) );
        pigfile.selected = 0;

        for (i = 0; i < pigfile.num_options; i++) {
            pignames[i][strlen(pignames[i]) - 4] = 0;
            checkmem( pigfile.options[i] = MALLOC(strlen(pignames[i]) + 1) );
            strcpy( (char *)pigfile.options[i], pignames[i] );

            for (j = 1; j < strlen(pigfile.options[i]); j++) {
                *( (char *)pigfile.options[i] + j ) = tolower(
                    pigfile.options[i][j]);
            }

            strcat(pignames[i], ".256");

            if ( l && !strcmp(pignames[i], l->pigname) ) {
                pigfile.selected = i;
            }

            FREE(pignames[i]);
        }

        FREE(pignames);
        pigfile.select_lroutine = pigfile.select_rroutine = b_changepigfile;
    }

    checkmem( view.b_levels = MALLOC( sizeof(struct w_b_choose) ) );
    view.b_levels->num_options = 1;
    checkmem( view.b_levels->options = MALLOC(sizeof(char *) * 1) );
    view.b_levels->options[0] = TXT_NONE;
    view.b_levels->selected = 0;
    view.b_levels->select_lroutine = view.b_levels->select_rroutine =
                                         b_changelevel;
    bxsize = w_xwininsize(w) / 3;
    w_refreshstart(w);
    checkmem( b1 = b_currmode =
                       w_addstdbutton(w, w_b_choose, 0, y = 0, bxsize * 3, -1,
                                      TXT_MODIFYWHAT, &modifybutton,
                                      1) );
    y += b1->ysize;
    checkmem( b2 = b_movemode =
                       w_addstdbutton(w, w_b_choose, 0, y, bxsize * 3, -1,
                                      TXT_MOVEMODE, &modebutton, 1) );
    y += b2->ysize;
    checkmem( view.levelbutton =
                 w_addstdbutton(w, w_b_choose, 0, y, bxsize * 3, -1,
                                TXT_LEVEL, view.b_levels, 1) );
    y += view.levelbutton->ysize;

    if (init.d_ver >= d2_10_reg) {
        checkmem( b3 = b_pigfile =
                           w_addstdbutton(w, w_b_choose, 0, y, bxsize * 3, -1,
                                          TXT_LEVELPIGFILE, &pigfile,
                                          1) );
        y += b3->ysize;

        if (init.d_ver >= d2_12_reg) {
            pogfile.delay = 0;
            pogfile.repeat = -1;
            pogfile.l_pressed_routine = pogfile.r_pressed_routine = NULL;
            pogfile.l_routine = pogfile.r_routine = b_changepogfile;
            checkmem( b_pogfile =
                         w_addstdbutton(w, w_b_press, 0, y, bxsize * 3, -1,
                                        TXT_POGFILE, &pogfile, 1) );
            y += b_pogfile->ysize;
        }
    }

    bysize = (w_ywininsize(w) - y) / 2;

    /* move button menu */
    for (j = 5; j < 22; j++) {
        for (k = 1; k < 5; k += 2) {
            mbls[2][j * 5 + k] = -mbls[0][j * 5 + k];
            mbls[2][j * 5 + k + 1] = mbls[0][j * 5 + k + 1];
            mbls[4][j * 5 + k] = mbls[1][j * 5 + k];
//.........这里部分代码省略.........
开发者ID:j13s,项目名称:devil,代码行数:101,代码来源:grfx.c


示例3: disposeFpgmPrep

static INLINE void disposeFpgmPrep(MOVE table_fpgm_prep *table) {
	if (table->tag) sdsfree(table->tag);
	if (table->bytes) FREE(table->bytes);
}
开发者ID:anthrotype,项目名称:otfcc,代码行数:4,代码来源:fpgm-prep.c


示例4: mvg_triangulation_RANSAC


//.........这里部分代码省略.........
		CvMat * X = 
			affine ? mvg_triangulation_SVD_affine(projection_matrices, projected_points, normalize_A, 2, samples, 2)
			       : mvg_triangulation_SVD(projection_matrices, projected_points, normalize_A, 2, samples, 2);
		if (!X)
		{
			continue;
		}

		// count and mark the inliers
		int inliers_count = 0;
		for (int j = 0; j < n; j++)
		{
			double reprojection[2];
			// note that here we're using "dirty" projection method which is suitable only for visualization; on the upside, it shouldn't matter because
			// if a point is projected on pi_infinity, there's something wrong with it anyway
			if (affine) 
			{
				opencv_vertex_projection_visualization(projection_matrices[j], OPENCV_ELEM(X, 0, 0), OPENCV_ELEM(X, 1, 0), OPENCV_ELEM(X, 2, 0), reprojection);
			}
			else
			{
				opencv_vertex_projection_visualization(projection_matrices[j], OPENCV_ELEM(X, 0, 0), OPENCV_ELEM(X, 1, 0), OPENCV_ELEM(X, 2, 0), OPENCV_ELEM(X, 3, 0), reprojection);
			}

			const double
				dx = reprojection[0] - OPENCV_ELEM(projected_points, 0, j), 
				dy = reprojection[1] - OPENCV_ELEM(projected_points, 1, j);
			
			if (dx * dx + dy * dy <= threshold_sq)
			{
				inliers_count++; 
				status[j] = true; 
			}
			else
			{
				status[j] = false;
			}
		}

		cvReleaseMat(&X);

		// check for the best sample 
		if (inliers_count > best_inliers_count)
		{
			bool * temp = best_status; 
			best_status = status; 
			status = temp;
			best_inliers_count = inliers_count; 
		}

		// debug 
		// printf("{%d/%d} ", inliers_count, n);
	}

	FREE(status);
	if (best_inliers_count < 2)
	{
		FREE(best_status);
		return false;
	}

	// calculate camera calibration using only inliers
	int * samples = ALLOC(int, best_inliers_count);
	int j = 0;
	int outliers = 0, min = min_inliers_to_triangulate; 
	for (int i = 0; i < n; i++)
	{
		if (best_status[i]) 
		{
			samples[j++] = i;
		}
		else
		{
			outliers++;
		}
	}

	if (outliers == 0) min = min_inliers_to_triangulate_weaker;
	CvMat * X = affine ? mvg_triangulation_SVD_affine(projection_matrices, projected_points, true, min, samples, best_inliers_count)
	                   : mvg_triangulation_SVD(projection_matrices, projected_points, true, min, samples, best_inliers_count);
	if (!X)
	{
		// printf("failed to estimate\n"); 
		if (inliers) 
		{
			memset(inliers, 0, sizeof(bool) * n);
		}
	}
	else if (inliers)
	{
		memcpy(inliers, best_status, sizeof(bool) * n);
	}

	// release resources
	FREE(samples);
	FREE(best_status);

	// printf("\n");
	return X;
}
开发者ID:HWiese1980,项目名称:insight3d,代码行数:101,代码来源:mvg_triangulation.cpp


示例5: krb5_rc_dfl_recover_locked

static krb5_error_code
krb5_rc_dfl_recover_locked(krb5_context context, krb5_rcache id)
{
#ifdef NOIOSTUFF
    return KRB5_RC_NOIO;
#else

    struct dfl_data *t = (struct dfl_data *)id->data;
    krb5_donot_replay *rep = 0;
    krb5_error_code retval;
    long max_size;
    int expired_entries = 0;
    krb5_int32 now;

    if ((retval = krb5_rc_io_open(context, &t->d, t->name))) {
	return retval;
    }

    t->recovering = 1;

    max_size = krb5_rc_io_size(context, &t->d);

    rep = NULL;
    if (krb5_rc_io_read(context, &t->d, (krb5_pointer) &t->lifespan,
			sizeof(t->lifespan))) {
	retval = KRB5_RC_IO;
	goto io_fail;
    }

    if (!(rep = (krb5_donot_replay *) malloc(sizeof(krb5_donot_replay)))) {
	retval = KRB5_RC_MALLOC;
	goto io_fail;
    }
    rep->client = NULL;
    rep->server = NULL;

    if (krb5_timeofday(context, &now))
	now = 0;

    /* now read in each auth_replay and insert into table */
    for (;;) {
	if (krb5_rc_io_mark(context, &t->d)) {
	    retval = KRB5_RC_IO;
	    goto io_fail;
	}

	retval = krb5_rc_io_fetch(context, t, rep, (int) max_size);

	if (retval == KRB5_RC_IO_EOF)
	    break;
	else if (retval != 0)
	    goto io_fail;


	if (alive(now, rep, t->lifespan) != CMP_EXPIRED) {
	    if (rc_store(context, id, rep, now) == CMP_MALLOC) {
		retval = KRB5_RC_MALLOC; goto io_fail;
	    }
	} else {
	    expired_entries++;
	}
	/*
	 *  free fields allocated by rc_io_fetch
	 */
	FREE(rep->server);
	FREE(rep->client);
	rep->server = 0;
	rep->client = 0;
    }
    retval = 0;
    krb5_rc_io_unmark(context, &t->d);
    /*
     *  An automatic expunge here could remove the need for
     *  mark/unmark but that would be inefficient.
     */
io_fail:
    krb5_rc_free_entry(context, &rep);
    if (retval)
	krb5_rc_io_close(context, &t->d);
    else if (expired_entries > EXCESSREPS)
	retval = krb5_rc_dfl_expunge_locked(context, id);
    t->recovering = 0;
    return retval;

#endif
}
开发者ID:aosm,项目名称:Kerberos,代码行数:86,代码来源:rc_dfl.c


示例6: val_log_assertion_pfx

void
val_log_assertion_pfx(const val_context_t * ctx, int level,
                      const char *prefix, const char * name_pr,
                      struct val_authentication_chain *next_as)
{
    char            name_buf[INET6_ADDRSTRLEN + 1];
    const char     *serv_pr;
    int             tag = 0;
    int             class_h;
    int             type_h;
    struct          val_rr_rec  *data;
    struct          val_rr_rec  *sig;
    struct          sockaddr *serv;
    val_astatus_t   status;
    struct val_rr_rec  *curkey, *cursig;


    if (next_as == NULL)
        return;

    class_h = next_as->val_ac_rrset->val_rrset_class;
    type_h = next_as->val_ac_rrset->val_rrset_type;
    data = next_as->val_ac_rrset->val_rrset_data;
    sig = next_as->val_ac_rrset->val_rrset_sig;
    serv = next_as->val_ac_rrset->val_rrset_server;
    status = next_as->val_ac_status;

    if (NULL == prefix)
        prefix = "";

    if (serv)
        serv_pr =
            ((serv_pr =
              val_get_ns_string(serv, name_buf, sizeof(name_buf))) == NULL) ?  "VAL_CACHE" : serv_pr;
    else
        serv_pr = "NULL";

    if (type_h == ns_t_dnskey) {
        for (curkey = data; curkey; curkey = curkey->rr_next) {
            if ((curkey->rr_status == VAL_AC_VERIFIED_LINK) ||
                (curkey->rr_status == VAL_AC_TRUST_POINT) ||
                (curkey->rr_status == VAL_AC_UNKNOWN_ALGORITHM_LINK)) {
                /*
                 * Extract the key tag 
                 */
                val_dnskey_rdata_t dnskey;
                if (VAL_NO_ERROR != val_parse_dnskey_rdata(curkey->rr_rdata,
                                       curkey->rr_rdata_length, &dnskey)) {
                    val_log(ctx, LOG_INFO, "val_log_assertion_pfx(): Cannot parse DNSKEY data");
                } else {
                    tag = dnskey.key_tag;
                    if (dnskey.public_key)
                        FREE(dnskey.public_key);
                }
                break;
            }
        }
    }

    if (tag != 0) {
        val_log(ctx, level,
                "%sname=%s class=%s type=%s[tag=%d] from-server=%s "
                "status=%s:%d", prefix, name_pr, p_class(class_h),
                p_type(type_h), tag, serv_pr, p_ac_status(status), status);
    } else {
        val_log(ctx, level,
                "%sname=%s class=%s type=%s from-server=%s status=%s:%d",
                prefix, name_pr, p_class(class_h), p_type(type_h), serv_pr,
                p_ac_status(status), status);
    }
#if 0
    for (cursig = sig; cursig; cursig = cursig->rr_next) {
        char incpTime[1028];
        char exprTime[1028];
        struct timeval  tv_sig;
        val_rrsig_rdata_t rrsig;

        val_parse_rrsig_rdata(cursig->rr_rdata, cursig->rr_rdata_length, &rrsig);

        memset(&tv_sig, 0, sizeof(tv_sig));
        tv_sig.tv_sec = rrsig.sig_incp;
        GET_TIME_BUF((const time_t *)(&tv_sig.tv_sec), incpTime);

        memset(&tv_sig, 0, sizeof(tv_sig));
        tv_sig.tv_sec = rrsig.sig_expr;
        GET_TIME_BUF((const time_t *)(&tv_sig.tv_sec), exprTime);

        val_log(ctx, level,
                "%s    ->tag=%d status=%s sig-incep=%s sig-expr=%s",
                prefix, rrsig.key_tag,
                p_ac_status(cursig->rr_status),
                incpTime, exprTime);
    }
#endif

#if 0
    struct val_rr_rec  *rr;
    struct val_rr_rec  *sig = next_as->val_ac_rrset->val_rrset_sig;
    for (rr = data; rr; rr = rr->rr_next) {
        val_log(ctx, level, "    data_status=%s:%d",
//.........这里部分代码省略.........
开发者ID:ajufrancis,项目名称:dnssec-tools,代码行数:101,代码来源:val_log.c


示例7: finish

/*
 * Creates the config file and tells i3 to reload.
 *
 */
static void finish() {
    printf("creating \"%s\"...\n", config_path);

    if (!(dpy = XOpenDisplay(NULL)))
        errx(1, "Could not connect to X11");

    FILE *kc_config = fopen(SYSCONFDIR "/i3/config.keycodes", "r");
    if (kc_config == NULL)
        err(1, "Could not open input file \"%s\"", SYSCONFDIR "/i3/config.keycodes");

    FILE *ks_config = fopen(config_path, "w");
    if (ks_config == NULL)
        err(1, "Could not open output config file \"%s\"", config_path);
    free(config_path);

    char *line = NULL;
    size_t len = 0;
#ifndef USE_FGETLN
    ssize_t read;
#endif
    bool head_of_file = true;

    /* write a header about auto-generation to the output file */
    fputs("# This file has been auto-generated by i3-config-wizard(1).\n", ks_config);
    fputs("# It will not be overwritten, so edit it as you like.\n", ks_config);
    fputs("#\n", ks_config);
    fputs("# Should you change your keyboard layout some time, delete\n", ks_config);
    fputs("# this file and re-run i3-config-wizard(1).\n", ks_config);
    fputs("#\n", ks_config);

#ifdef USE_FGETLN
    char *buf = NULL;
    while ((buf = fgetln(kc_config, &len)) != NULL) {
        /* fgetln does not return null-terminated strings */
        FREE(line);
        sasprintf(&line, "%.*s", len, buf);
#else
    size_t linecap = 0;
    while ((read = getline(&line, &linecap, kc_config)) != -1) {
        len = strlen(line);
#endif
        /* skip the warning block at the beginning of the input file */
        if (head_of_file &&
            strncmp("# WARNING", line, strlen("# WARNING")) == 0)
            continue;

        head_of_file = false;

        /* Skip leading whitespace */
        char *walk = line;
        while (isspace(*walk) && walk < (line + len)) {
            /* Pre-output the skipped whitespaces to keep proper indentation */
            fputc(*walk, ks_config);
            walk++;
        }

        /* Set the modifier the user chose */
        if (strncmp(walk, "set $mod ", strlen("set $mod ")) == 0) {
            if (modifier == MOD_Mod1)
                fputs("set $mod Mod1\n", ks_config);
            else
                fputs("set $mod Mod4\n", ks_config);
            continue;
        }

        /* Check for 'bindcode'. If it’s not a bindcode line, we
         * just copy it to the output file */
        if (strncmp(walk, "bindcode", strlen("bindcode")) != 0) {
            fputs(walk, ks_config);
            continue;
        }
        char *result = rewrite_binding(walk);
        fputs(result, ks_config);
        free(result);
    }

    /* sync to do our best in order to have the file really stored on disk */
    fflush(ks_config);
    fsync(fileno(ks_config));

#ifndef USE_FGETLN
    free(line);
#endif

    fclose(kc_config);
    fclose(ks_config);

    /* tell i3 to reload the config file */
    int sockfd = ipc_connect(socket_path);
    ipc_send_message(sockfd, strlen("reload"), 0, (uint8_t *)"reload");
    close(sockfd);

    exit(0);
}

int main(int argc, char *argv[]) {
//.........这里部分代码省略.........
开发者ID:Fresne,项目名称:i3-1,代码行数:101,代码来源:main.c


示例8: dres_free_value

/********************
 * dres_free_value
 ********************/
void
dres_free_value(dres_value_t *val)
{
    if (val && val->type == DRES_TYPE_STRING)
        FREE(val->v.s);
}
开发者ID:maemo-foss,项目名称:maemo-multimedia-dres,代码行数:9,代码来源:dres.c


示例9: dres_free_field

/********************
 * dres_free_field
 ********************/
void
dres_free_field(dres_field_t *f)
{
    FREE(f->name);
    dres_free_value(&f->value);
}
开发者ID:maemo-foss,项目名称:maemo-multimedia-dres,代码行数:9,代码来源:dres.c


示例10: eGrep


//.........这里部分代码省略.........
					"\n-v, --invert-match\tSelect non-matching lines (uncompatible with -o)\n"
					"\n    --help\t\tDisplay this help and exit\n"
					"\nOutput control :\n"
					"\n-m, --max-count=NUM\tStop searching in a file after NUM matching lines\n"
					"\n-b, --byte-offset\tPrint the byte offset for each output lines,\n"
					"\t\t\twhen combined with -o print the offset of the match\n"
					"\n-n, --line-number\tPrint line number with outuput lines (starts at 1)\n"
					"\n-H, --with-filename\tPrint the filename for each match (default when having\n\t\t\tmore than one FILE)\n"
					"\n-h, --no-filename\tSuppress the file name prefix on output (default when\n\t\t\thaving only one FILE)\n"
					"\n-o, --only-matching\tDisplays only the part of a line matching the pattern,\n"
					"\t\t\tin the case of multiple matches per line, displays\n\t\t\tas many lines as matches\n"
					"\t\t\tuncompatible with -v, -e and -E\n"
					"\n-q, --quiet, --silent\tSuppress all normal output\n"
					"\n-R, -r, --recursive\tSearch recursively in each files contained in FILE\n"
					"\n--include=GLOB\t\tSearch only files whose base name matches GLOB\n"
					"\n--exclude=GLOB\t\tSkip   files  whose  base  name  matches  GLOB\n"
					"\n--exclude-dir=DIR\tExclude directories matching  the  pattern  DIR\n\t\t\tfrom  recursive searches\n"
					"\n-L, --files-without-match Print only names of FILEs containing no match\n"
					"\n-l, --file-with-matches\tPrint only names of FILEs containing matches\n"
					"\n-c, --count\t\tprint only a count of matching lines per FILE\n"
					"\n-Z, --null\t\tPrint 0 byte after FILE name\n"
					"\nSpecial handling : if '-' is given as PATTERN, PATTERN become the standard input"
					"\nExit status :\n\n" 
					"0 if no results were found\n"
					"1 if at least one result was found\n"
					"2 if an error was given\n\n"
					

				);
		quit = 1;
	}

	if (!quit && args->options != NULL &&  (*(Options*)args->options->data).name == 'V' && args->files == NULL && args->pattern == NULL)
	{
		printf( 
				"Grep command revised :\n\n"
				"version : %d.%d.%d\n\n"
				"authors :\n\tBASSET Cyril\n\tLAMBERTI Jean-Vincent\n\tPICARD David\n\n"
				,GREP_STATUS,GREP_MAJOR_VERSION,GREP_MINOR_VERSION);
		quit = 1;
	}


	if(!quit && args->pattern == NULL)
	{
		if(!hasOption('s', args->options) && !hasOption('q', args->options))
			printf("Pattern not found.\n");
		return_val = 2;
		quit = 1;
	}

	if(!quit && (!args->files || !args->pattern))
		quit = 1;

	if (!quit)
	{
		if (args->files != NULL)
		{

			Maillon* lines = NULL;
			int file_count = 0;
			if(hasOption('r',args->options))
			{
				Maillon* files = NULL;
				Maillon* next = args->files;
				while(next != NULL)
				{
					getFileFrom((char*)next->data,&files,args->options);
					next = next->next;
				}
				lines = nFileLoader(files, hasOption('z',args->options));
				file_count = listSize(files);
			}
			else
			{
				lines = nFileLoader(args->files, hasOption('z',args->options));
				file_count = listSize(args->files);
			}

			if (lines != NULL)
			{
				Maillon* results = extractWithPattern(lines, args->pattern, args->options);
				if (!hasOption('q', args->options))
					displayFileLine(results, file_count, args);
				return_val = listSize(results) > 0 ? 0 : 1 ;
				//listSize(results)>0?return_val=0:return_val=1;
			}
		}
	}

	if (args != NULL)
	{
		//freeList(&(args->options));
		// Do not free pattern!!! It's the argv[i] address
		//freeList(&(args->files));
		FREE(args);
	}

	return return_val;
}
开发者ID:kinroux,项目名称:grep,代码行数:101,代码来源:grep.c


示例11: main

main(int    argc,
     char **argv)
{
char        *pagedir, *pagesubstr, *maskdir, *masksubstr;
char        *title, *fileout, *boxaafile, *boxaapath;
l_int32      ret, res, type, thresh;
l_float32    scalefactor;
BOXAA       *baa;
static char  mainName[] = "convertsegfilestopdf";

    if (argc != 12) {
        fprintf(stderr,
	    " Syntax: convertsegfilestopdf dirin substr res type thresh \\ \n"
            "                       boxaafile scalefactor title fileout\n"
            "     where\n"
            "         pagedir:  input directory for image files\n"
            "         pagesubstr:  Use 'allfiles' to convert all files\n"
            "                  in the directory\n"
            "         maskdir:  input directory for mask files;\n"
            "                   use 'skip' to skip \n"
            "         masksubstr:  Use 'allfiles' to convert all files\n"
            "                  in the directory; 'skip' to skip\n"
            "         res:  Input resolution of each image;\n"
            "               assumed to all be the same\n"
            "         type: compression used for non-image regions:\n"
            "               0: default (G4 encoding)\n"
            "               1: JPEG encoding\n"
            "               2: G4 encoding\n"
            "               3: PNG encoding\n"
            "         thresh:  threshold for binarization; use 0 for default\n"
            "         boxaafile: Optional file of 'image' regions within\n"
            "                    each page.  This contains a boxa for each\n"
            "                    page, consisting of a set of regions.\n"
            "                    Use 'skip' to skip.\n"
            "         scalefactor:  Use to scale down the image regions\n"
            "         title:  Use 'none' to omit\n"
            "         fileout:  Output pdf file\n");
        return 1;
    }

    pagedir = argv[1];
    pagesubstr = argv[2];
    maskdir = argv[3];
    masksubstr = argv[4];
    res = atoi(argv[5]);
    type = atoi(argv[6]);
    thresh = atoi(argv[7]);
    boxaafile = argv[8];
    scalefactor = atof(argv[9]);
    title = argv[10];
    fileout = argv[11];

    if (!strcmp(pagesubstr, "allfiles"))
        pagesubstr = NULL;
    if (!strcmp(maskdir, "skip"))
        maskdir = NULL;
    if (!strcmp(masksubstr, "allfiles"))
        masksubstr = NULL;
    if (scalefactor <= 0.0 || scalefactor > 1.0) {
        L_WARNING("invalid scalefactor: setting to 1.0", mainName);
        scalefactor = 1.0;
    }
    if (type != 1 && type != 2 && type != 3)
        type = L_G4_ENCODE;
    if (thresh <= 0)
        thresh = 150;
    if (!strcmp(title, "none"))
        title = NULL;

    if (maskdir)  /* use this; ignore any input boxaafile */
        baa = convertNumberedMasksToBoxaa(maskdir, masksubstr, 0, 0);
    else if (strcmp(boxaafile, "skip")) {  /* use the boxaafile */
        boxaapath = genPathname(boxaafile, NULL);
        baa = boxaaRead(boxaapath);
        FREE(boxaapath);
    } 
    else  /* no maskdir and no input boxaafile */
        baa = NULL;

    ret = convertSegmentedFilesToPdf(pagedir, pagesubstr, res, type, thresh,
                                     baa, 75, scalefactor, title, fileout);
    boxaaDestroy(&baa);
    return ret;
}
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:84,代码来源:convertsegfilestopdf.c


示例12: llvm_pipeline_generic

static void
llvm_pipeline_generic( struct draw_pt_middle_end *middle,
                       const struct draw_fetch_info *fetch_info,
                       const struct draw_prim_info *in_prim_info )
{
   struct llvm_middle_end *fpme = (struct llvm_middle_end *)middle;
   struct draw_context *draw = fpme->draw;
   struct draw_geometry_shader *gshader = draw->gs.geometry_shader;
   struct draw_prim_info gs_prim_info;
   struct draw_vertex_info llvm_vert_info;
   struct draw_vertex_info gs_vert_info;
   struct draw_vertex_info *vert_info;
   struct draw_prim_info ia_prim_info;
   struct draw_vertex_info ia_vert_info;
   const struct draw_prim_info *prim_info = in_prim_info;
   boolean free_prim_info = FALSE;
   unsigned opt = fpme->opt;
   unsigned clipped = 0;

   llvm_vert_info.count = fetch_info->count;
   llvm_vert_info.vertex_size = fpme->vertex_size;
   llvm_vert_info.stride = fpme->vertex_size;
   llvm_vert_info.verts =
      (struct vertex_header *)MALLOC(fpme->vertex_size *
                                     align(fetch_info->count,  lp_native_vector_width / 32));
   if (!llvm_vert_info.verts) {
      assert(0);
      return;
   }

   if (draw->collect_statistics) {
      draw->statistics.ia_vertices += fetch_info->count;
      draw->statistics.ia_primitives +=
         u_decomposed_prims_for_vertices(prim_info->prim, prim_info->count);
      draw->statistics.vs_invocations += fetch_info->count;
   }

   if (fetch_info->linear)
      clipped = fpme->current_variant->jit_func( &fpme->llvm->jit_context,
                                       llvm_vert_info.verts,
                                       (const char **)draw->pt.user.vbuffer,
                                       fetch_info->start,
                                       fetch_info->count,
                                       fpme->vertex_size,
                                       draw->pt.vertex_buffer,
                                       draw->instance_id);
   else
      clipped = fpme->current_variant->jit_func_elts( &fpme->llvm->jit_context,
                                            llvm_vert_info.verts,
                                            (const char **)draw->pt.user.vbuffer,
                                            fetch_info->elts,
                                            fetch_info->count,
                                            fpme->vertex_size,
                                            draw->pt.vertex_buffer,
                                            draw->instance_id);

   /* Finished with fetch and vs:
    */
   fetch_info = NULL;
   vert_info = &llvm_vert_info;


   if ((opt & PT_SHADE) && gshader) {
      struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
      draw_geometry_shader_run(gshader,
                               draw->pt.user.gs_constants,
                               draw->pt.user.gs_constants_size,
                               vert_info,
                               prim_info,
                               &vshader->info,
                               &gs_vert_info,
                               &gs_prim_info);

      FREE(vert_info->verts);
      vert_info = &gs_vert_info;
      prim_info = &gs_prim_info;
   } else {
      if (draw_prim_assembler_is_required(draw, prim_info, vert_info)) {
         draw_prim_assembler_run(draw, prim_info, vert_info,
                                 &ia_prim_info, &ia_vert_info);

         if (ia_vert_info.count) {
            FREE(vert_info->verts);
            vert_info = &ia_vert_info;
            prim_info = &ia_prim_info;
            free_prim_info = TRUE;
         }
      }
   }

   /* stream output needs to be done before clipping */
   draw_pt_so_emit( fpme->so_emit, vert_info, prim_info );

   /*
    * if there's no position, need to stop now, or the latter stages
    * will try to access non-existent position output.
    */
   if (draw_current_shader_position_output(draw) != -1) {
      if ((opt & PT_SHADE) && gshader) {
         clipped = draw_pt_post_vs_run( fpme->post_vs, vert_info );
//.........这里部分代码省略.........
开发者ID:mthuurne,项目名称:mesa,代码行数:101,代码来源:draw_pt_fetch_shade_pipeline_llvm.c


示例13: render_destroy

static void render_destroy( struct draw_stage *stage )
{
   FREE( stage );
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:4,代码来源:i915_prim_emit.c


示例14: ALLOC

/*
 * NAME:	hfs->create()
 * DESCRIPTION:	create and open a new file
 */
hfsfile *hfs_create(hfsvol *vol, const char *path,
		    const char *type, const char *creator)
{
  hfsfile *file = 0;
  unsigned long parid;
  char name[HFS_MAX_FLEN + 1];
  CatKeyRec key;
  byte record[HFS_MAX_CATRECLEN];
  unsigned reclen;
  int found;

  if (getvol(&vol) == -1)
    goto fail;

  file = ALLOC(hfsfile, 1);
  if (file == 0)
    ERROR(ENOMEM, 0);

  found = v_resolve(&vol, path, &file->cat, &parid, name, 0);
  if (found == -1 || parid == 0)
    goto fail;

  if (found)
    ERROR(EEXIST, 0);

  if (parid == HFS_CNID_ROOTPAR)
    ERROR(EINVAL, 0);

  if (vol->flags & HFS_VOL_READONLY)
    ERROR(EROFS, 0);

  /* create file `name' in parent `parid' */

  if (bt_space(&vol->cat, 1) == -1)
    goto fail;

  f_init(file, vol, vol->mdb.drNxtCNID++, name);
  vol->flags |= HFS_VOL_UPDATE_MDB;

  file->parid = parid;

  /* create catalog record */

  file->cat.u.fil.filUsrWds.fdType =
    d_getsl((const unsigned char *) type);
  file->cat.u.fil.filUsrWds.fdCreator =
    d_getsl((const unsigned char *) creator);

  file->cat.u.fil.filCrDat = d_mtime(time(0));
  file->cat.u.fil.filMdDat = file->cat.u.fil.filCrDat;

  r_makecatkey(&key, file->parid, file->name);
  r_packcatrec(&key, &file->cat, record, &reclen);

  if (bt_insert(&vol->cat, record, reclen) == -1 ||
      v_adjvalence(vol, file->parid, 0, 1) == -1)
    goto fail;

  /* package file handle for user */

  file->next = vol->files;
  file->refs = 1;
  if (vol->files)
    vol->files->prev = file;

  vol->files = file;

  return file;

fail:
  FREE(file);
  return 0;
}
开发者ID:andyvand,项目名称:fusehfs,代码行数:77,代码来源:hfs.c


示例15: import_heap_image


//.........这里部分代码省略.........
    if (params->oldest_agegroup_keeping_idle_fromspace_buffers < 0) {
        params->oldest_agegroup_keeping_idle_fromspace_buffers = heap_header.oldest_agegroup_keeping_idle_fromspace_buffers;
    } 

    task = make_task( FALSE, params );						// make_task		def in   src/c/main/runtime-state.c

    // Get the run-time pointers into the heap:
    //
    *PTR_CAST( Val*, PERVASIVE_PACKAGE_PICKLE_LIST_REFCELL__GLOBAL )
        =
        heap_header.pervasive_package_pickle_list;

    // This carefully constructed fake looks like a normal
    // compiled package from the Mythryl side but actually
    // links to compile C code -- see the hack in
    //	
    //     src/c/main/load-compiledfiles.c
    //
    runtime_package__global =  heap_header.runtime_pseudopackage;

    #ifdef ASM_MATH
	mathvec__global = heap_header.math_package;
    #endif


    externs = heapio__read_externs_table (&inbuf);		// Read the externals table.

    READ(&inbuf, image);				// Read and initialize the Mythryl state info.
    //
    if (image_header.kind == EXPORT_HEAP_IMAGE) {

        // Load the live registers:
        //
	ASSIGN( POSIX_INTERPROCESS_SIGNAL_HANDLER_REFCELL__GLOBAL, image.posix_interprocess_signal_handler );
	//
	task->argument		= image.stdArg;
	task->fate		= image.stdCont;
	task->current_closure	= image.stdClos;
	task->program_counter	= image.pc;
	task->exception_fate	= image.exception_fate;
	task->current_thread	= image.current_thread;
	//
	task->callee_saved_registers[0]	= image.calleeSave[0];
	task->callee_saved_registers[1]	= image.calleeSave[1];
	task->callee_saved_registers[2]	= image.calleeSave[2];

	read_heap (&inbuf, &heap_header, task, externs);			// Read the Mythryl heap.

	/* cleaner_messages_are_enabled__global = TRUE; */					// Cleaning messages are on by default for interactive images.

    } else { 								// EXPORT_FN_IMAGE

        Val function_to_run;
	Val program_name;
	Val args;

        // Restore the signal handler:
        //
	ASSIGN( POSIX_INTERPROCESS_SIGNAL_HANDLER_REFCELL__GLOBAL, image.posix_interprocess_signal_handler );

        // Read the Mythryl heap:
        //
	task->argument		= image.stdArg;
	read_heap (&inbuf, &heap_header, task, externs);

        // Initialize the calling context (taken from run_mythryl_function):					// run_mythryl_function		def in   src/c/main/run-mythryl-code-and-runtime-eventloop.c
        //
	function_to_run		= task->argument;
	//
	task->exception_fate	= PTR_CAST( Val,  handle_uncaught_exception_closure_v + 1 );
	task->current_thread	= HEAP_VOID;
	//
	task->fate		= PTR_CAST( Val,  return_to_c_level_c );
	task->current_closure	= function_to_run;
	//
	task->program_counter	=
	task->link_register	= GET_CODE_ADDRESS_FROM_CLOSURE( function_to_run );

        // Set up the arguments to the imported function:
        //
	program_name = make_ascii_string_from_c_string(task, mythryl_program_name__global);
	args = make_ascii_strings_from_vector_of_c_strings (task, commandline_arguments);
	REC_ALLOC2(task, task->argument, program_name, args);

	// debug_say("arg = %#x : [%#x, %#x]\n", task->argument, GET_TUPLE_SLOT_AS_VAL(task->argument, 0), GET_TUPLE_SLOT_AS_VAL(task->argument, 1));

        // Cleaner messages are off by
        // default for spawn_to_disk images:
        //
	cleaner_messages_are_enabled__global =  FALSE;
    }

    FREE( externs );

    if (inbuf.file)   fclose (inbuf.file);

    if (verbosity > 0)   say(" done\n");

    return task;
}								// fun import_heap_image
开发者ID:spiralofhope,项目名称:mythryl,代码行数:101,代码来源:import-heap.c


示例16: calculate_visibility

/**
 * calculate_visibility - Are tree nodes visible
 * @param ctx       Mailbox
 * @param max_depth Maximum depth to check
 *
 * this calculates whether a node is the root of a subtree that has visible
 * nodes, whether a node itself is visible, whether, if invisible, it has
 * depth anyway, and whether any of its later siblings are roots of visible
 * subtrees.  while it's at it, it frees the old thread display, so we can
 * skip parts of the tree in mutt_draw_tree() if we've decided here that we
 * don't care about them any more.
 */
static void calculate_visibility(struct Context *ctx, int *max_depth)
{
  struct MuttThread *tmp = NULL, *tree = ctx->tree;
  int hide_top_missing = C_HideTopMissing && !C_HideMissing;
  int hide_top_limited = C_HideTopLimited && !C_HideLimited;
  int depth = 0;

  /* we walk each level backwards to make it easier to compute next_subtree_visible */
  while (tree->next)
    tree = tree->next;
  *max_depth = 0;

  while (true)
  {
    if (depth > *max_depth)
      *max_depth = depth;

    tree->subtree_visible = 0;
    if (tree->message)
    {
      FREE(&tree->message->tree);
      if (is_visible(tree->message, ctx))
      {
        tree->deep = true;
        tree->visible = true;
        tree->message->display_subject = need_display_subject(ctx, tree->message);
        for (tmp = tree; tmp; tmp = tmp->parent)
        {
          if (tmp->subtree_visible)
          {
            tmp->deep = true;
            tmp->subtree_visible = 2;
            break;
          }
          else
            tmp->subtree_visible = 1;
        }
      }
      else
      {
        tree->visible = false;
        tree->deep = !C_HideLimited;
      }
    }
    else
    {
      tree->visible = false;
      tree->deep = !C_HideMissing;
    }
    tree->next_subtree_visible =
        tree->next && (tree->next->next_subtree_visible || tree->next->subtree_visible);
    if (tree->child)
    {
      depth++;
      tree = tree->child;
      while (tree->next)
        tree = tree->next;
    }
    else if (tree->prev)
      tree = tree->prev;
    else
    {
      while (tree && !tree->prev)
      {
        depth--;
        tree = tree->parent;
      }
      if (!tree)
        break;
      else
        tree = tree->prev;
    }
  }

  /* now fix up for the OPTHIDETOP* options if necessary */
  if (hide_top_limited || hide_top_missing)
  {
    tree = ctx->tree;
    while (true)
    {
      if (!tree->visible && tree->deep && (tree->subtree_visible < 2) &&
          ((tree->message && hide_top_limited) || (!tree->message && hide_top_missing)))
      {
        tree->deep = false;
      }
      if (!tree->deep && tree->child && tree->subtree_visible)
        tree = tree->child;
      else if (tree->next)
//.........这里部分代码省略.........
开发者ID:kdave,项目名称:neomutt,代码行数:101,代码来源:mutt_thread.c


示例17: load_file_banded_imp

static void load_file_banded_imp(const char *file, const char *band,
                                 int reset_location, int multilook)
{
    char *old_file = NULL;
    if (curr->filename) {
      old_file = STRDUP(curr->filename);
      free(curr->filename);
      curr->filename = NULL;
    }

    reset_globals(reset_location);
    asfPrintStatus("\nLoading: %s\n", file);

    // start loading of the new file
    curr->filename = STRDUP(file);

    // strip off a trailing "."
    if (curr->filename[strlen(curr->filename)-1] == '.')
        curr->filename[strlen(curr->filename)-1] = '\0';

    // Determine if the current file is a new file
    static char *last_file = NULL;
    int new_file = 0;
    if (!last_file) last_file = STRDUP(curr->filename);
    if (last_file && strcmp(last_file, curr->filename) != 0) {
      new_file = 1;
      FREE(last_file);
      last_file = STRDUP(curr->filename);
    }

    if (read_file(curr->filename, band, multilook, FALSE)) {
      int dummy;
      char lut[256];
      static int tiff_lut_exists = 0;
      static int asf_colormap_exists = 0;
      char embedded_tiff_lut_file[1024];
      char embedded_asf_colormap_file[1024];
      char *lut_loc = (char *)MALLOC(sizeof(char)*(strlen(get_asf_share_dir())+128));
      sprintf(lut_loc, "%s%clook_up_tables", get_asf_share_dir(), DIR_SEPARATOR);
      sprintf(embedded_tiff_lut_file,"%s%c%s&quo 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FREEGLUT_EXIT_IF_NOT_INITIALISED函数代码示例发布时间:2022-05-30
下一篇:
C++ FRAMEWIN_GetDefaultClientColor函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap