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

C++ sbuf_free函数代码示例

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

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



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

示例1: entry_changed

// Return -1 for error, 0 for entry not changed, 1 for entry changed (or new).
static int entry_changed(struct sbuf *sb,
	struct manios *manios, struct asfd *chfd, struct sbuf **csb)
{
	static int finished=0;
	static struct blk *blk=NULL;

	if(finished) return 1;

	if((*csb)->path.buf)
	{
		// Already have an entry.
	}
	else
	{
		// Need to read another.
		if(!blk && !(blk=blk_alloc())) return -1;
		switch(manio_read_with_blk(manios->current,
			*csb, blk, NULL))
		{
			case 1: // Reached the end.
				sbuf_free(csb);
				blk_free(&blk);
				finished=1;
				return 1;
			case -1: return -1;
		}
		if(!(*csb)->path.buf)
		{
			logp("Should have a path at this point, but do not, in %s\n", __func__);
			return -1;
		}
		// Got an entry.
	}

	while(1)
	{
		switch(sbuf_pathcmp(*csb, sb))
		{
			case 0: return found_in_current_manifest(*csb, sb,
					manios, &blk, chfd);
			case 1: return 1;
			case -1:
				// Behind - need to read more data from the old
				// manifest.
				switch(manio_read_with_blk(manios->current,
					*csb, blk, NULL))
				{
					case 1: // Reached the end.
						sbuf_free(csb);
						blk_free(&blk);
						return 1;
					case -1: return -1;
				}
				// Got something, go back around the loop.
		}
	}

	return 0;
}
开发者ID:EmisFR,项目名称:burp,代码行数:60,代码来源:backup_phase2.c


示例2: pkg_delete

int
pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
{
	struct pkg **rdeps;
	int i, ret;
	struct sbuf *rdep_msg;

	if (pkg == NULL)
		return (ERROR_BAD_ARG("pkg"));

	if (db == NULL)
		return (ERROR_BAD_ARG("db"));

	/*
	 * Ensure that we have all the informations we need
	 */
	if ((ret = pkgdb_loadrdeps(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadfiles(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadscripts(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadmtree(db, pkg)) != EPKG_OK)
		return (ret);

	rdeps = pkg_rdeps(pkg);

	if (rdeps[0] != NULL) {
		rdep_msg = sbuf_new_auto();
		sbuf_printf(rdep_msg, "%s-%s is required by other packages:", pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION));
		for (i = 0;rdeps[i] != NULL; i++) {
			sbuf_cat(rdep_msg, " ");
			sbuf_printf(rdep_msg, "%s-%s", pkg_get(rdeps[i], PKG_NAME), pkg_get(rdeps[i], PKG_VERSION));
		}
		if (!force) {
			sbuf_finish(rdep_msg);
			ret = pkg_error_set(EPKG_REQUIRED, "%s", sbuf_get(rdep_msg));
			sbuf_free(rdep_msg);
			return ret;
		}
		sbuf_cat(rdep_msg, ", deleting anyway");
		sbuf_finish(rdep_msg);
		fprintf(stderr, "%s\n", sbuf_get(rdep_msg));
		sbuf_free(rdep_msg);
	}

	if ((ret = pkg_script_pre_deinstall(pkg)) != EPKG_OK)
		return (ret);

	if ((ret = pkg_delete_files(pkg, force)) != EPKG_OK)
		return (ret);

	if ((ret = pkg_script_post_deinstall(pkg)) != EPKG_OK)
		return (ret);

	return (pkgdb_unregister_pkg(db, pkg_get(pkg, PKG_ORIGIN)));
}
开发者ID:flz,项目名称:pkgng,代码行数:57,代码来源:pkg_delete.c


示例3: forward_past_entry

static
#endif
int forward_past_entry(struct manio *manio, struct iobuf *target,
                       enum protocol protocol, man_off_t **pos)
{
    struct sbuf *sb=NULL;

    if(!(sb=sbuf_alloc(protocol)))
        goto error;

    man_off_t_free(pos);
    if(!(*pos=manio_tell(manio)))
    {
        logp("Could not manio_tell first pos in %s(): %s\n",
             __func__, strerror(errno));
        goto error;
    }

    while(1)
    {
        sbuf_free_content(sb);
        switch(manio_read(manio, sb))
        {
        case 0:
            break;
        case 1:
            logp("End of file in %s()\n", __func__);
            goto error;
        default:
            logp("Error in %s()\n", __func__);
            // Treat error in unchanged manio as not OK.
            goto error;
        }

        if(target->cmd==sb->path.cmd
                && !pathcmp(target->buf, sb->path.buf))
        {
            man_off_t_free(pos);
            if(!(*pos=manio_tell(manio)))
            {
                logp("Could not get pos in %s(): %s\n",
                     __func__, strerror(errno));
                goto error;
            }
            sbuf_free(&sb);
            return 0;
        }
    }

error:
    sbuf_free(&sb);
    man_off_t_free(pos);
    return -1;
}
开发者ID:ZungBang,项目名称:burp,代码行数:54,代码来源:resume.c


示例4: do_test_check_browsedir_windows_blank

END_TEST

static void do_test_check_browsedir_windows_blank(enum protocol protocol)
{
	struct sbuf *mb;
	const char *browsedir;
	char *last_bd_match=NULL;

	fail_unless((mb=sbuf_alloc(protocol))!=NULL);

	browsedir="";
	run_check_browsedir(browsedir, mb, CMD_FILE, "A:/aaa",
		&last_bd_match, "A:", 1, 1);
	run_check_browsedir(browsedir, mb, CMD_DIRECTORY, "C:/aaa",
		&last_bd_match, "C:", 1, 1);
	run_check_browsedir(browsedir, mb, CMD_FILE, "C:/aaa/file",
		&last_bd_match, "C:", 0, 1);
	run_check_browsedir(browsedir, mb, CMD_FILE, "C:/aaa/filx",
		&last_bd_match, "C:", 0, 1);
	run_check_browsedir(browsedir, mb, CMD_FILE, "D:/adf",
		&last_bd_match, "D:", 1, 1);

	sbuf_free(&mb);
	free_w(&last_bd_match);
	alloc_check();
}
开发者ID:EmisFR,项目名称:burp,代码行数:26,代码来源:test_list.c


示例5: read_phase1

// Used on resume, this just reads the phase1 file and sets up cntr.
static int read_phase1(struct manio *p1manio, struct conf **cconfs)
{
    int ret=-1;
    struct sbuf *p1b;
    enum protocol protocol=get_protocol(cconfs);
    struct cntr *cntr=get_cntr(cconfs);
    if(!(p1b=sbuf_alloc(protocol))) return -1;
    while(1)
    {
        sbuf_free_content(p1b);
        switch(manio_read(p1manio, p1b))
        {
        case 0:
            break;
        case 1:
            ret=0;
        default:
            goto end;
        }
        cntr_add_phase1(cntr, p1b->path.cmd, 0);

        if(sbuf_is_estimatable(p1b))
            cntr_add_val(cntr, CMD_BYTES_ESTIMATED,
                         (uint64_t)p1b->statp.st_size);
    }
end:
    sbuf_free(&p1b);
    return ret;
}
开发者ID:ZungBang,项目名称:burp,代码行数:30,代码来源:resume.c


示例6: do_backup_phase2_client

static int do_backup_phase2_client(struct asfd *asfd,
	struct conf *conf, int resume)
{
	int ret=-1;
	// For efficiency, open Windows files for the VSS data, and do not
	// close them until another time around the loop, when the actual
	// data is read.
	BFILE bfd;
	// Windows VSS headers tell us how much file
	// data to expect.
	size_t datalen=0;
#ifdef HAVE_WIN32
	binit(&bfd, 0, conf);
#endif

	struct sbuf *sb=NULL;
	struct iobuf *rbuf=asfd->rbuf;

	if(!(sb=sbuf_alloc(conf))) goto end;

	if(!resume)
	{
		// Only do this bit if the server did not tell us to resume.
		if(asfd->write_str(asfd, CMD_GEN, "backupphase2")
		  || asfd->read_expect(asfd, CMD_GEN, "ok"))
			goto end;
	}
	else if(conf->send_client_cntr)
	{
		// On resume, the server might update the client with cntr.
		if(cntr_recv(asfd, conf)) goto end;
	}

	while(1)
	{
		iobuf_free_content(rbuf);
		if(asfd->read(asfd)) goto end;
		else if(!rbuf->buf) continue;

		if(rbuf->cmd==CMD_GEN && !strcmp(rbuf->buf, "backupphase2end"))
		{
			if(asfd->write_str(asfd, CMD_GEN, "okbackupphase2end"))
				goto end;
			ret=0;
			break;
		}

		if(parse_rbuf(asfd, sb, &bfd, &datalen, conf))
			goto end;
	}

end:
#ifdef HAVE_WIN32
	// It is possible for a bfd to still be open.
	close_file_for_sendl(&bfd, NULL, asfd);
#endif
	iobuf_free_content(rbuf);
	sbuf_free(sb);
	return ret;
}
开发者ID:jkniiv,项目名称:burp,代码行数:60,代码来源:backup_phase2.c


示例7: START_TEST

END_TEST

START_TEST(test_check_browsedir_alloc_error)
{
	char *path;
	size_t bdlen;
	struct sbuf *mb;
	const char *browsedir;
	char *last_bd_match=NULL;

	fail_unless((mb=sbuf_alloc(PROTO_1))!=NULL);

	browsedir="";
	bdlen=0;
	fail_unless((path=strdup_w("aaa", __func__))!=NULL);
	iobuf_from_str(&mb->path, CMD_FILE, path);
	alloc_errors=1;
	fail_unless(check_browsedir(
		browsedir,
		mb,
		bdlen,
		&last_bd_match)
			==-1);

	sbuf_free(&mb);
	free_w(&last_bd_match);
	alloc_check();
}
开发者ID:EmisFR,项目名称:burp,代码行数:28,代码来源:test_list.c


示例8: pkg_free

void
pkg_free(struct pkg *pkg)
{
	if (pkg == NULL)
		return;

	ucl_object_unref(pkg->fields);

	for (int i = 0; i < PKG_NUM_SCRIPTS; i++)
		sbuf_free(pkg->scripts[i]);

	pkg_list_free(pkg, PKG_DEPS);
	pkg_list_free(pkg, PKG_RDEPS);
	pkg_list_free(pkg, PKG_FILES);
	pkg_list_free(pkg, PKG_DIRS);
	pkg_list_free(pkg, PKG_OPTIONS);
	pkg_list_free(pkg, PKG_USERS);
	pkg_list_free(pkg, PKG_GROUPS);
	pkg_list_free(pkg, PKG_SHLIBS_REQUIRED);
	pkg_list_free(pkg, PKG_SHLIBS_PROVIDED);
	if (pkg->rootfd != -1)
		close(pkg->rootfd);

	free(pkg);
}
开发者ID:AsherBond,项目名称:pkg,代码行数:25,代码来源:pkg.c


示例9: get_wbuf_from_scan

static void get_wbuf_from_scan(struct iobuf *wbuf, struct slist *flist)
{
	struct sbuf *sb=flist->head;
	if(!sb) return;
	if(!(sb->flags & SBUF_SENT_STAT))
	{
		iobuf_copy(wbuf, &sb->attr);
		sb->flags |= SBUF_SENT_STAT;
	}
	else if(!(sb->flags & SBUF_SENT_PATH))
	{
		iobuf_copy(wbuf, &sb->path);
		sb->flags |= SBUF_SENT_PATH;
	}
	else if(sb->link.buf && !(sb->flags & SBUF_SENT_LINK))
	{
		iobuf_copy(wbuf, &sb->link);
		sb->flags |= SBUF_SENT_LINK;
	}
	else
	{
		flist->head=flist->head->next;
		sbuf_free(&sb);
		if(flist->head)
		{
			// Go ahead and get the next one from the list.
			get_wbuf_from_scan(wbuf, flist);
		}
		else
		{
			flist->tail=NULL;
			iobuf_from_str(wbuf, CMD_GEN, (char *)"scan_end");
		}
	}
}
开发者ID:Sherlock221B,项目名称:burp,代码行数:35,代码来源:backup_phase2.c


示例10: do_test_check_browsedir_null_or_blank

END_TEST

static void do_test_check_browsedir_null_or_blank(enum protocol protocol,
	const char *browsedir)
{
	struct sbuf *mb;
	char *last_bd_match=NULL;

	fail_unless((mb=sbuf_alloc(protocol))!=NULL);

	run_check_browsedir(browsedir, mb, CMD_FILE, "aaa",
		&last_bd_match, "aaa",  1, 0);
	run_check_browsedir(browsedir, mb, CMD_DIRECTORY, "/",
		&last_bd_match, "/",    1, 1);
	run_check_browsedir(browsedir, mb, CMD_DIRECTORY, "/asdf",
		&last_bd_match, "/",    0, 1);
	run_check_browsedir(browsedir, mb, CMD_DIRECTORY, "/asdf/blah",
		&last_bd_match, "/",    0, 1);
	run_check_browsedir(browsedir, mb, CMD_FILE, "zzz",
		&last_bd_match, "zzz",  1, 0);
	run_check_browsedir(browsedir, mb, CMD_FILE, "zzzz//",
		&last_bd_match, "zzzz",  1, 1);

	sbuf_free(&mb);
	free_w(&last_bd_match);
	alloc_check();
}
开发者ID:EmisFR,项目名称:burp,代码行数:27,代码来源:test_list.c


示例11: update_window_names

/* Note that we use marked_message_internal to avoid resetting the
   alarm. */
void
update_window_names (rp_screen *s, char *fmt)
{
  struct sbuf *bar_buffer;
  int mark_start = 0;
  int mark_end = 0;

  if (s->bar_is_raised != BAR_IS_WINDOW_LIST) return;

  bar_buffer = sbuf_new (0);

  if(defaults.window_list_style == STYLE_ROW)
    {
      get_window_list (fmt, NULL, bar_buffer, &mark_start, &mark_end);
      marked_message_internal (sbuf_get (bar_buffer), mark_start, mark_end);
    }
  else
    {
      get_window_list (fmt, "\n", bar_buffer, &mark_start, &mark_end);
      marked_message_internal (sbuf_get (bar_buffer), mark_start, mark_end);
    }


/*   marked_message (sbuf_get (bar_buffer), mark_start, mark_end); */
  sbuf_free (bar_buffer);
}
开发者ID:devanstroud,项目名称:ratpoison,代码行数:28,代码来源:bar.c


示例12: browse_manifest_start

static int browse_manifest_start(struct asfd *srfd, struct cstat *cstat,
	struct bu *bu, const char *browse, struct conf **confs)
{
	int ret=-1;
	char *manifest=NULL;
	struct sbuf *sb=NULL;
	struct manio *manio=NULL;

	if(!(manifest=prepend_s(bu->path,
		cstat->protocol==PROTO_1?"manifest.gz":"manifest"))
	  || !(manio=manio_alloc())
	  || manio_init_read(manio, manifest)
	  || !(sb=sbuf_alloc_protocol(cstat->protocol)))
		goto end;
	manio_set_protocol(manio, cstat->protocol);
	if(get_int(confs[OPT_MONITOR_BROWSE_CACHE]))
		ret=cache_load(srfd, manio, sb, cstat, bu);
	else
		ret=do_browse_manifest(srfd, manio, sb, browse);
end:
	free_w(&manifest);
	manio_free(&manio);
	sbuf_free(&sb);
	return ret;
}
开发者ID:Shloub,项目名称:burp,代码行数:25,代码来源:browse.c


示例13: get_primary_selection

/* Lifted the code from rxvt. */
static char *
get_primary_selection(void)
{
  long            nread;
  unsigned long   bytes_after;
  XTextProperty   ct;
  struct sbuf *s = sbuf_new(0);

  for (nread = 0, bytes_after = 1; bytes_after > 0; nread += ct.nitems) {
    if ((XGetWindowProperty(dpy, current_screen()->input_window, rp_selection, (nread / 4), 4096,
                            True, AnyPropertyType, &ct.encoding,
                            &ct.format, &ct.nitems, &bytes_after,
                            &ct.value) != Success)) {
      XFree(ct.value);
      sbuf_free(s);
      return NULL;
    }
    if (ct.value == NULL)
      continue;
    /* Accumulate the data. FIXME: ct.value may not be NULL
       terminated. */
    sbuf_nconcat (s, ct.value, ct.nitems);
    XFree(ct.value);
  }
  return sbuf_free_struct (s);
}
开发者ID:melkior,项目名称:nilwm,代码行数:27,代码来源:globals.c


示例14: write_to_changed_file

static int write_to_changed_file(struct asfd *asfd,
	struct asfd *chfd, struct manios *manios,
	struct slist *slist, int end_flags)
{
	struct sbuf *sb;
	if(!slist) return 0;

	while((sb=slist->head))
	{
		if(sb->flags & SBUF_NEED_DATA)
		{
			switch(sbuf_needs_data(sb, asfd, chfd, manios, slist,
				end_flags))
			{
				case 0: return 0;
				case 1: continue;
				default: return -1;
			}

		}
		else
		{
			// No change, can go straight in.
			if(manio_write_sbuf(manios->changed, sb)) return -1;
			if(write_endfile(sb, manios)) return -1;

			// Move along.
			slist->head=sb->next;

			sanity_before_sbuf_free(slist, sb);
			sbuf_free(&sb);
		}
	}
	return 0;
}
开发者ID:pkdevbox,项目名称:burp,代码行数:35,代码来源:backup_phase2.c


示例15: restore_remaining_dirs

static int restore_remaining_dirs(struct asfd *asfd, struct bu *bu,
	struct slist *slist, enum action act, struct sdirs *sdirs,
	enum cntr_status cntr_status, struct conf **cconfs)
{
	int ret=-1;
	struct sbuf *sb;
	struct sbuf *need_data=NULL;
	if(!(need_data=sbuf_alloc(get_protocol(cconfs)))) goto end;
	// Restore any directories that are left in the list.
	for(sb=slist->head; sb; sb=sb->next)
	{
		if(get_protocol(cconfs)==PROTO_1)
		{
			if(restore_sbuf_protocol1(asfd, sb, bu, act,
				sdirs, cntr_status, cconfs))
					goto end;
		}
		else
		{
			if(restore_sbuf_protocol2(asfd, sb, act,
				cntr_status, get_cntr(cconfs), need_data))
					goto end;
		}
	}
	ret=0;
end:
	sbuf_free(&need_data);
	return ret;
}
开发者ID:pkdevbox,项目名称:burp,代码行数:29,代码来源:restore.c


示例16: pr_any_valsx

/*
 * Print a number of variable values for NcML
 */
static void
pr_any_valsx(
     const ncvar_t *vp,		/* variable */
     size_t len,		/* number of values to print */
     bool_t more,		/* true if more data for this row will
				 * follow, so add trailing comma */
     bool_t lastrow,		/* true if this is the last row for this
				 * variable, so terminate with ";" instead
				 * of "," */
     const void *vals		/* pointer to block of values */
     )
{
    long iel;
    safebuf_t *sb = sbuf_new();
    const char *valp = (const char *)vals;

    for (iel = 0; iel < len-1; iel++) {
	print_any_val(sb, vp, (void *)valp);
	valp += vp->tinfo->size; /* next value according to type */
	sbuf_cat(sb, " ");
	lput(sbuf_str(sb));
    }
    print_any_val(sb, vp, (void *)valp);
    lput(sbuf_str(sb));
    lastdelim2x (more, lastrow);
    sbuf_free(sb);
}
开发者ID:ArtisticCoding,项目名称:libmesh,代码行数:30,代码来源:vardata.c


示例17: free_sbufls

void free_sbufls(struct sbuf **sb, int count)
{
	int s=0;
	if(!sb) return;
	for(s=0; s<count; s++) sbuf_free(&(sb[s]));
	free_v((void **)&sb);
}
开发者ID:Kalimeiro,项目名称:burp,代码行数:7,代码来源:sbufl.c


示例18: term_commit

void term_commit(void)
{
	if (term_sbuf) {
		write(1, sbuf_buf(term_sbuf), sbuf_len(term_sbuf));
		sbuf_free(term_sbuf);
		term_sbuf = NULL;
	}
}
开发者ID:litcave,项目名称:neatvi,代码行数:8,代码来源:term.c


示例19: pkg_conflict_free

void
pkg_conflict_free(struct pkg_conflict *c)
{
	if (c == NULL)
		return;

	sbuf_free(c->glob);
	free(c);
}
开发者ID:flz,项目名称:pkgng,代码行数:9,代码来源:pkg_conflict.c


示例20: maybe_add_from_scan

static int maybe_add_from_scan(struct manios *manios,
	struct slist *slist, struct asfd *chfd, struct sbuf **csb)
{
	int ret=-1;
	struct sbuf *snew=NULL;

	while(1)
	{
		sbuf_free(&snew);
		if(!manios->phase1) return 0;
		// Limit the amount loaded into memory at any one time.
		if(slist && slist->head)
		{
			if(slist->head->protocol2->index
			  - slist->tail->protocol2->index>4096)
				return 0;
		}
		if(!(snew=sbuf_alloc(PROTO_2))) goto end;

		switch(manio_read(manios->phase1, snew))
		{
			case 0: break;
			case 1: manio_close(&manios->phase1);
				ret=0; // Finished.
			default: goto end;
		}

		switch(entry_changed(snew, manios, chfd, csb))
		{
			case 0: continue; // No change.
			case 1: break;
			default: goto end; // Error.
		}

		if(data_needed(snew)) snew->flags|=SBUF_NEED_DATA;

		slist_add_sbuf(slist, snew);
		snew=NULL;
	}
	return 0;
end:
	sbuf_free(&snew);
	return ret;
}
开发者ID:EmisFR,项目名称:burp,代码行数:44,代码来源:backup_phase2.c



注:本文中的sbuf_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ sbuf_new_auto函数代码示例发布时间:2022-05-30
下一篇:
C++ sbuf_delete函数代码示例发布时间: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