当前位置: 首页>>代码示例>>C++>>正文


C++ splice函数代码示例

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


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

示例1: splice_test

static void splice_test(void)
{
	int pipes[2];
	int ret;

	fd_in = SAFE_OPEN(cleanup, TESTFILE1, O_RDONLY);
	SAFE_PIPE(cleanup, pipes);
	fd_out = SAFE_OPEN(cleanup, TESTFILE2, O_WRONLY | O_CREAT | O_TRUNC, 0666);

	ret = splice(fd_in, NULL, pipes[1], NULL, TEST_BLOCK_SIZE, 0);
	if (ret < 0)
		tst_brkm(TBROK | TERRNO, cleanup, "splice(fd_in, pipe) failed");

	ret = splice(pipes[0], NULL, fd_out, NULL, TEST_BLOCK_SIZE, 0);
	if (ret < 0)
		tst_brkm(TBROK | TERRNO, cleanup, "splice(pipe, fd_out) failed");

	close(fd_in);
	close(fd_out);
	close(pipes[0]);
	close(pipes[1]);

	fd_out = 0;
	fd_in = 0;

	check_file();
}
开发者ID:Nudiv,项目名称:ltp,代码行数:27,代码来源:splice01.c

示例2: splice

void Subdivision::deleteEdge(Edge *e)
{
    splice(e, e->Oprev());
    splice(e->Sym(), e->Sym()->Oprev());

    delete e;
}
开发者ID:derkreature,项目名称:img2sky,代码行数:7,代码来源:subdivision.cpp

示例3: place

/* 
 * Requires:
 *   "bp" is the address of a free block that is at least "asize" bytes.
 *
 * Effects:
 *   Place a block of "asize" bytes at the start of the free block "bp" and
 *   split that block if the remainder would be at least the minimum block
 *   size. 
 */
static void
place(void *bp, size_t asize)
{
	size_t csize = GET_SIZE(HDRP(bp));
	struct node *nodep = (struct node *) bp;
	struct node *new_nodep;

	/* increased size to account for next and previous pointer overhead */
	if ((csize - asize) >= (ASIZE + QSIZE)) { 
		PUT(HDRP(bp), PACK(asize, 1));
		PUT(FTRP(bp), PACK(asize, 1));
		
		bp = NEXT_BLKP(bp);
		PUT(HDRP(bp), PACK(csize - asize, 0));
		PUT(FTRP(bp), PACK(csize - asize, 0));
		
		/* Set new node for the leftover free block */
		new_nodep = (struct node *)bp;
		
		new_nodep->previous = nodep->previous;
		new_nodep->next = nodep->next;
				
		/* Remove node from allocated block */
		splice(nodep);
		
	} else {
		PUT(HDRP(bp), PACK(csize, 1));
		PUT(FTRP(bp), PACK(csize, 1));
		
		/* Remove node from allocated block */
		splice(nodep);
	}
	checkheap(1);
}
开发者ID:gowtamvamsi,项目名称:COMP321-malloc,代码行数:43,代码来源:mm.c

示例4: create_key_pair

// There is no scenario requiring a public key, we support it for completeness.
bool create_key_pair(encrypted_private& out_private,
    encrypted_public& out_public, ec_compressed& out_point,
    const encrypted_token& token, const ek_seed& seed, uint8_t version,
    bool compressed)
{
    const parse_encrypted_token parse(token);
    if (!parse.valid())
        return false;

    const auto point = splice(parse.sign(), parse.data());
    auto point_copy = point;
    const auto factor = bitcoin_hash(seed);
    if (!ec_multiply(point_copy, factor))
        return false;

    ek_salt salt;
    if (!address_salt(salt, point_copy, version, compressed))
        return false;

    const auto salt_entropy = splice(salt, parse.entropy());
    const auto derived = split(scrypt_pair(point, salt_entropy));
    const auto flags = set_flags(compressed, parse.lot_sequence(), true);

    if (!create_public_key(out_public, flags, salt, parse.entropy(),
        derived.left, derived.right, factor, version))
        return false;

    create_private_key(out_private, flags, salt, parse.entropy(), derived.left,
        derived.right, seed, version);

    out_point = point_copy;
    return true;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:34,代码来源:encrypted_keys.cpp

示例5: find_module

// 查找模块的名称
void find_module(char* scan_mode,char* find_modules)
{
	DIR *dirp;

	int find_status = 0;

	char* this_path;
	// 路径尾部组合
	char* path_last = splice("plugins/",splice(scan_mode,"/"));
	// 全路径
	char* path_obj = splice(defpath(),path_last);

	dirp = opendir(path_obj);

	if(dirp != NULL)
	{
		while(1)
		{
			direntp = readdir(dirp);

			if(direntp == NULL){
				break;
			}else if(direntp->d_name[0] != '.'){
				if (strcmp(direntp->d_name,find_modules) == 0){
					printf("[*] Find modules Path: %s ,Plugin: %s \n",path[path_index],direntp->d_name);
					find_status = find_status + 1;
				}
			}
		}
		if (find_status < 1){
			printf("[*] Can't not found this module.\n");
		}
		closedir(dirp);
	}
}
开发者ID:hxp2k6,项目名称:smart7ec-scan-console,代码行数:36,代码来源:main.c

示例6: main

int main(int argc, char *argv[])
{
    if(argc != 2) {
        printf("Usage: %s <file>\n", basename(argv[0]));
        exit(EXIT_FAILURE);
    }
    int filefd = open(argv[1], O_CREAT | O_WRONLY | O_TRUNC, 0666);
    if(filefd == -1)
        ERR_EXIT("open");
    int pipefd_stdout[2];
    int ret = pipe(pipefd_stdout);
    if(ret == -1)
        ERR_EXIT("pipe");
    int pipefd_file[2];
    ret = pipe(pipefd_file);
    if(ret == -1)
        ERR_EXIT("pipe");

    if(splice(STDIN_FILENO, NULL, pipefd_stdout[1], NULL, 32768, SPLICE_F_MORE | SPLICE_F_MOVE) == -1)
        ERR_EXIT("splice");
    if(tee(pipefd_stdout[0], pipefd_file[1], 32768, SPLICE_F_NONBLOCK) == -1)
        ERR_EXIT("tee");
    if(splice(pipefd_file[0], NULL, filefd, NULL, 32768, SPLICE_F_MORE | SPLICE_F_MOVE) == -1)
        ERR_EXIT("splice");
    if(splice(pipefd_stdout[0], NULL, STDOUT_FILENO, NULL, 32768, SPLICE_F_MORE | SPLICE_F_MOVE) == -1)
        ERR_EXIT("splice");
    close(filefd);
    close(pipefd_stdout[0]);
    close(pipefd_stdout[1]);
    close(pipefd_file[0]);
    close(pipefd_file[1]);
    exit(EXIT_SUCCESS);
}
开发者ID:bashell,项目名称:np,代码行数:33,代码来源:test_tee.c

示例7: begin

void List<Type>::merge(List &list, Predicate predicate)
{
    Iterator iter1 = begin();
    Iterator iter2 = list.begin();

    Iterator last1 = end();
    Iterator last2 = list.end();

    while (iter1 != last1 && iter2 != last2)
    {
        // check whether [predicate] is true
        if (predicate(*iter1, *iter2))
        {
            ++iter1;
        }
        else
        {
            // move element at location [iter2] to this list before [iter1]
            Iterator position = iter2++;
            splice(iter1, list, position, iter2);
        }
    }

    splice(last1, list, iter2, last2);
}
开发者ID:jason2506,项目名称:Linked-List,代码行数:25,代码来源:list-implement.hpp

示例8: if

void terminalImpl::createSplicedTerminals() {
	unsigned int lI = 0;
	unsigned int hI = 0;
	bool joinable;
	for (unsigned int index = 0; index < highestIndex - lowestIndex; ++index) {
		bitTerminal& t0 = bitTerminals.at(lowestIndex + index);
		bitTerminal& t1 = bitTerminals.at(lowestIndex + index + 1);
		if (t0.isConst && t1.isConst)
			joinable = true;
		else if (t0.isConst || t1.isConst)
			joinable = false;
		else {
			joinable = true;
			std::unordered_set<bitTerminal*> lowerBitTerminal;
			for (auto&& cBT : t1.connectedBitNet->connectedBitTerminals) {
				int lesserIndex = cBT->index;
				lesserIndex--;
				if (lesserIndex < 0) {
					joinable = false;
					break;
				} else
					lowerBitTerminal.insert(&cBT->baseTerminal->bitTerminals.at(lesserIndex));
			}
			joinable &= (t0.connectedBitNet->connectedBitTerminals == lowerBitTerminal);
		}

		if (joinable)
			hI++;
		else {
			splice(lowestIndex + hI, lowestIndex + lI);
			lI = ++hI;
		}
	}
	splice(lowestIndex + hI, lowestIndex + lI);
}
开发者ID:RishabhRawat,项目名称:schematicGenerator,代码行数:35,代码来源:terminalImpl.cpp

示例9: str_list

// 输出所有插件列表
void str_list(void)
{
	DIR *dirp;

	printf("[*] Loading Plugin List ...\n");

	for (path_index = 0; path_index < 4; path_index++)
	{
		char* this_path;
		// 路径尾部组合
		char* path_last = splice("plugins/",splice(path[path_index],"/"));
		// 全路径
		char* path_obj = splice(defpath(),path_last);

		dirp = opendir(path_obj);

		if(dirp != NULL)
		{
			while(1)
			{
				direntp = readdir(dirp);

				if(direntp == NULL){
					break;
				}else if(direntp->d_name[0] != '.'){
					printf("[*] Path: %s ,Plugin: %s \n",path[path_index],direntp->d_name);
				}
			}
			closedir(dirp);
		}	
    }
}
开发者ID:hxp2k6,项目名称:smart7ec-scan-console,代码行数:33,代码来源:main.c

示例10: makeEdge

EdgePointer CDelaunay::connectRight(EdgePointer a, EdgePointer b)
{
  EdgePointer ans;
  ans = makeEdge(dest(a), orig(b));
  splice(ans, (EdgePointer) sym(a));
  splice((EdgePointer) sym(ans), (EdgePointer) oprev(b));
  return(ans);
}
开发者ID:cile,项目名称:android_packages_apps_Camera,代码行数:8,代码来源:Delaunay.cpp

示例11: connect

// connects the a.dst to b.org through a new edge
edge connect(edge a, edge b) {
    Edge_Record er = make_edge();
    er.get_qr().v = a.dst();
    er.sym().get_qr().v = b.org();
    splice(er, a.lnext());
    splice(er.sym(), b);
    return er;
}
开发者ID:axiao,项目名称:delaunay,代码行数:9,代码来源:quadedge.cpp

示例12: stress_splice

/*
 *  stress_splice
 *	stress copying of /dev/zero to /dev/null
 */
int stress_splice(
	uint64_t *const counter,
	const uint32_t instance,
	const uint64_t max_ops,
	const char *name)
{
	int fd_in, fd_out, fds[2];

	if (!set_splice_bytes) {
		if (opt_flags & OPT_FLAGS_MAXIMIZE)
			opt_splice_bytes = MAX_SPLICE_BYTES;
		if (opt_flags & OPT_FLAGS_MINIMIZE)
			opt_splice_bytes = MIN_SPLICE_BYTES;
	}

	(void)instance;

	if (pipe(fds) < 0) {
		pr_failed_err(name, "pipe");
		return EXIT_FAILURE;
	}

	if ((fd_in = open("/dev/zero", O_RDONLY)) < 0) {
		(void)close(fds[0]);
		(void)close(fds[1]);
		pr_failed_err(name, "open");
		return EXIT_FAILURE;
	}
	if ((fd_out = open("/dev/null", O_WRONLY)) < 0) {
		(void)close(fd_in);
		(void)close(fds[0]);
		(void)close(fds[1]);
		pr_failed_err(name, "open");
		return EXIT_FAILURE;
	}

	do {
		int ret;

		ssize_t bytes;

		bytes = splice(fd_in, NULL, fds[1], NULL, opt_splice_bytes, SPLICE_F_MOVE);
		if (bytes < 0)
			break;

		ret = splice(fds[0], NULL, fd_out, NULL, opt_splice_bytes, SPLICE_F_MOVE);
		if (ret < 0)
			break;

		(*counter)++;
	} while (opt_do_run && (!max_ops || *counter < max_ops));
	(void)close(fd_out);
	(void)close(fd_in);
	(void)close(fds[0]);
	(void)close(fds[1]);

	return EXIT_SUCCESS;
}
开发者ID:srikanth007m,项目名称:stress-ng,代码行数:62,代码来源:stress-splice.c

示例13: makeEdge

QuadEdge *connect( QuadEdge *a, QuadEdge *b ) {
  QuadEdge *e = makeEdge();
  e->setOrg( a->Dest() );
  e->setDest( b->Org() );
  splice( e, a->Lnext() );
  splice( e->Sym(), b );

  return e;
}
开发者ID:dose78,项目名称:FRPA,代码行数:9,代码来源:edge.cpp

示例14: splice

void List<Type>::swap(List &list)
{
    List copy;

    // exchang the elements of this list with [list]
    splice(copy.begin(), list);
    splice(list.begin(), *this);
    splice(begin(), copy);
}
开发者ID:jason2506,项目名称:Linked-List,代码行数:9,代码来源:list-implement.hpp

示例15: deleteEdge

void deleteEdge( QuadEdge *e ) {
  splice( e, e->Oprev() );
  splice( e->Sym(), e->Sym()->Oprev() );

  delete e->Rotinv();
  delete e->Sym();
  delete e->Rot();
  delete e;
}
开发者ID:dose78,项目名称:FRPA,代码行数:9,代码来源:edge.cpp


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