本文整理汇总了C++中splice函数的典型用法代码示例。如果您正苦于以下问题:C++ splice函数的具体用法?C++ splice怎么用?C++ splice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了splice函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例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,代码来源:subdivision.cpp
示例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,代码来源:stress-splice.c
示例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,代码来源:atee.c
示例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,代码来源:quadedge.cpp
示例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,代码来源:mm.c
注:本文中的splice函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论