本文整理匯總了C++中BZERO函數的典型用法代碼示例。如果您正苦於以下問題:C++ BZERO函數的具體用法?C++ BZERO怎麽用?C++ BZERO使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BZERO函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: auth_withpeer_fail
/*
* We have failed to authenticate ourselves to the peer using `protocol'.
*/
void
auth_withpeer_fail(int unit, u16_t protocol)
{
int errCode = PPPERR_AUTHFAIL;
LWIP_UNUSED_ARG(protocol);
AUTHDEBUG((LOG_INFO, "auth_withpeer_fail: %d proto=%X\n", unit, protocol));
if (passwd_from_file) {
BZERO(ppp_settings.passwd, MAXSECRETLEN);
}
/*
* XXX Warning: the unit number indicates the interface which is
* not necessarily the PPP connection. It works here as long
* as we are only supporting PPP interfaces.
*/
pppIOCtl(unit, PPPCTLS_ERRCODE, &errCode);
/*
* We've failed to authenticate ourselves to our peer.
* He'll probably take the link down, and there's not much
* we can do except wait for that.
*/
lcp_close(unit, "Authentication failed");
}
示例2: GC_rebuild_root_index
STATIC void GC_rebuild_root_index(void)
{
int i;
BZERO(GC_root_index, RT_SIZE * sizeof(void *));
for (i = 0; i < n_root_sets; i++)
add_roots_to_index(GC_static_roots + i);
}
示例3: Save_Rip
/*
* saving what's found. Mainly music file here.
* PW_Start_Address & OutputSize are global .. not everybody likes
* that :(. I just cant seem to manage it otherwise.
*/
void Save_Rip ( char * format_to_save, int FMT_EXT )
{
Save_Status = BAD;
pw_write_log ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize );
if ( (PW_Start_Address + (long)OutputSize) > PW_in_size )
{
pw_write_log ( "!!! Truncated, missing (%ld byte(s) !)\n"
, (PW_Start_Address+OutputSize)-PW_in_size );
PW_i += 2 ;
return;
}
BZERO ( OutName_final, sizeof OutName_final);
sprintf ( OutName_final , "%ld.%s" , Cpt_Filename , Extensions[FMT_EXT] );
pw_write_log ( " saving in file \"%s\" ... " , OutName_final );
Cpt_Filename += 1;
PW_out = moduleripper2_fopen ( OutName_final , "w+b", format_to_save, PW_Start_Address, OutputSize);
//PW_out = PW_fopen ( OutName_final , "w+b" );
if (!PW_out)
return;
fwrite ( &in_data[PW_Start_Address] , OutputSize , 1 , PW_out );
fclose ( PW_out );
pw_write_log ( "done\n" );
if ( CONVERT == GOOD )
{
pw_write_log ( " converting to Protracker ... " );
}
//fflush ( stdout );
Save_Status = GOOD;
}
示例4: ChapMS
void
ChapMS( chap_state *cstate, char *rchallenge, int rchallenge_len, char *secret, int secret_len)
{
MS_ChapResponse response;
#ifdef MSLANMAN
extern int ms_lanman;
#endif
#if 0
CHAPDEBUG(LOG_INFO, ("ChapMS: secret is '%.*s'\n", secret_len, secret));
#endif
BZERO(&response, sizeof(response));
/* Calculate both always */
ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, &response);
#ifdef MSLANMAN
ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, &response);
/* prefered method is set by option */
response.UseNT = !ms_lanman;
#else
response.UseNT = 1;
#endif
BCOPY(&response, cstate->response, MS_CHAP_RESPONSE_LEN);
cstate->resp_length = MS_CHAP_RESPONSE_LEN;
}
示例5: vnlayer_linux_vattr2kstat
STATIC void
vnlayer_linux_vattr2kstat(
VATTR_T *src,
struct kstat *dst
)
{
BZERO(dst, sizeof(*dst));
/* We could assume all the "pullup" stuff happened in getattr so the inode
** matches what we have in the vattr and then use generic_fillattr(ip, dst)
** (and fix the dev field since it's not in the inode anymore). However,
** there could be a race on vob roots if we did that, so just get
** everything out of the passed in vattr structure.
*/
#define GET(lll, UUU) dst->lll = VATTR_GET_ ## UUU(src)
#define GET_TIME(lll, UUU) VATTR_GET_ ## UUU ## _TS(src, &(dst->lll))
GET(dev, FSID);
GET(ino, NODEID);
GET(mode, MODE);
dst->mode |= vnlayer_vtype_to_mode(VATTR_GET_TYPE(src));
GET(nlink, NLINK);
GET(uid, UID);
GET(gid, GID);
GET(rdev, RDEV);
GET_TIME(atime, ATIME);
GET_TIME(mtime, MTIME);
GET_TIME(ctime, CTIME);
GET(size, SIZE);
GET(blocks, NBLOCKS);
GET(blksize, BLKSIZE);
#undef GET_TIME
#undef GET
}
示例6: Save_Rip_Special
/*
* Special cases for files with header to rebuild ...
*
*/
void Save_Rip_Special ( char * format_to_save, int FMT_EXT, Uchar * Header_Block , Ulong Block_Size )
{
Save_Status = BAD;
pw_write_log ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize );
if ( (PW_Start_Address + (long)OutputSize) > PW_in_size )
{
pw_write_log ( "!!! Truncated, missing (%ld byte(s) !)\n"
, (PW_Start_Address+OutputSize)-PW_in_size );
PW_i += 2 ;
return;
}
BZERO (OutName_final, sizeof OutName_final);
sprintf ( OutName_final , "%ld.%s" , Cpt_Filename , Extensions[FMT_EXT] );
pw_write_log ( " saving in file \"%s\" ... " , OutName_final );
Cpt_Filename += 1;
// PW_out = PW_fopen ( OutName_final , "w+b" );
PW_out = moduleripper2_fopen ( OutName_final , "w+b", format_to_save, PW_Start_Address, OutputSize );
fwrite ( Header_Block , Block_Size , 1 , PW_out );
fwrite ( &in_data[PW_Start_Address] , OutputSize , 1 , PW_out );
fclose ( PW_out );
pw_write_log ( "done\n" );
if ( CONVERT == GOOD )
{
pw_write_log ( " converting to Protracker ... " );
}
pw_write_log ( " Header of this file was missing and has been rebuilt !\n" );
if ( FMT_EXT == DragPack252)
pw_write_log ( " WARNING !: it's a fake header since in this case !!\n" );
//fflush ( stdout );
Amiga_EXE_Header = GOOD;
Save_Status = GOOD;
}
示例7: ChapMS_NT
static void
ChapMS_NT( char *rchallenge,
int rchallenge_len,
char *secret,
int secret_len,
MS_ChapResponse *response)
{
int i;
MDstruct md4Context;
u_char unicodePassword[MAX_NT_PASSWORD * 2];
static int low_byte_first = -1;
LWIP_UNUSED_ARG(rchallenge_len);
/* Initialize the Unicode version of the secret (== password). */
/* This implicitly supports 8-bit ISO8859/1 characters. */
BZERO(unicodePassword, sizeof(unicodePassword));
for (i = 0; i < secret_len; i++) {
unicodePassword[i * 2] = (u_char)secret[i];
}
MDbegin(&md4Context);
MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */
if (low_byte_first == -1) {
low_byte_first = (PP_HTONS((unsigned short int)1) != 1);
}
if (low_byte_first == 0) {
/* @todo: arg type - u_long* or u_int* ? */
MDreverse((unsigned int*)&md4Context); /* sfb 961105 */
}
MDupdate(&md4Context, NULL, 0); /* Tell MD4 we're done */
ChallengeResponse((u_char*)rchallenge, (u_char*)md4Context.buffer, response->NTResp);
}
示例8: TestArgs1
// Test case: TestArgs:1
// This test case calls reloadIndexFromFile() and lookUp() and
// checks to make sure that all arguments are processed
// by the query engine successfully
int TestArgs1() {
START_TEST_CASE;
int lookUpResult = 0;
create();
INVERTED_INDEX* result = NULL;
result = reloadIndexFromFile("../indexer_dir/index.dat", indexReload);
SHOULD_BE(result != NULL);
LOG("Reloading INVERTED INDEX structure");
char query[1000] = "andrew";
sanitize(query);
char* queryList[1000];
curateWords(queryList, query);
SHOULD_BE(strcmp(queryList[0], "andrew") == 0);
sanitizeKeywords(queryList);
SHOULD_BE(strcmp(queryList[0], "andrew") == 0);
DocumentNode* saved[1000];
BZERO(saved, 1000);
lookUp(saved, queryList, indexReload);
lookUpResult = rankAndPrint(saved, "../crawler_dir/data");
SHOULD_BE(lookUpResult == 1);
cleanUpQueryList(queryList);
cleanUpIndex(indexReload);
END_TEST_CASE;
}
示例9: TestRanking1
// Test case: TestRanking:1
// This test case calls rankByFrequency() for the condition the DocumentNode
// page frequencies are different and need to be ranked accordingly
int TestRanking1() {
START_TEST_CASE;
DocumentNode* list1[1000];
BZERO(list1, 1000);
DocumentNode* docNode = NULL;
docNode = newDocNode(docNode, 1, 1);
DocumentNode* docNode2 = NULL;
docNode2 = newDocNode(docNode2, 16, 2);
DocumentNode* docNode3 = NULL;
docNode3 = newDocNode(docNode3, 1, 3);
DocumentNode* docNode4 = NULL;
docNode4 = newDocNode(docNode4, 1, 4);
list1[0] = docNode4;
list1[1] = docNode3;
list1[2] = docNode2;
list1[3] = docNode;
rankByFrequency(list1, 0, 3);
free(docNode);
free(docNode2);
free(docNode3);
free(docNode4);
END_TEST_CASE;
}
示例10: processSearchTerms
//takes in an array of search terms, gets the docID, score, and which list it should be added in
//and passes the information to the function addScoreToList to be added to the list
//
//PSEUDO CODE
//for all searchterms
// get the docIDs associated with the word and add the score to the list but factor in a WEIGHT
// if the prev searchterm is not OR
// add to list with weight
// else
// add to the list
void processSearchTerms(INVERTED_INDEX* index, char* searchterms) {
int docID;
int score;
char* prevterm = NULL;
char* currentterm;
int pos;
DOCNODE* d;
while (searchterms != NULL) {
currentterm = searchterms;
pos = 0;
if(isSearchTerm(currentterm) == TRUE) { //if it's a search term, normalize it and search for it
NormalizeWord(currentterm);
while((d = getDoc(index, currentterm, &pos)) != NULL) {
docID = d->doc_id;
score = d->page_word_freq;
if(isNotOR(prevterm) == TRUE) { //add with weighteded score because it must be ADD
addScoreToList(querylist, TRUE, docID, (score*WEIGHT));
}
else//add with regular score
addScoreToList(querylist, FALSE, docID, score);
}
}
prevterm = currentterm;
searchterms = strtok(NULL, " "); //get next searchterm
}
if (querylist->start != NULL) {
slist = NEW(SORTLIST);
MALLOC_CHECK(slist);
BZERO(slist, sizeof(SORTLIST));
sortList(slist, querylist);
printList(slist);
}
}
示例11: auth_withpeer_success
/*
* We have successfully authenticated ourselves with the peer using `protocol'.
*/
void auth_withpeer_success(int unit, u16_t protocol)
{
int pbit;
AUTHDEBUG((LOG_INFO, "auth_withpeer_success: %d proto=%X\n", unit, protocol));
switch (protocol) {
case PPP_CHAP:
pbit = CHAP_WITHPEER;
break;
case PPP_PAP:
if (passwd_from_file)
BZERO(ppp_settings.passwd, MAXSECRETLEN);
pbit = PAP_WITHPEER;
break;
default:
ppp_trace(LOG_WARNING, "auth_peer_success: unknown protocol %x\n",
protocol);
pbit = 0;
}
/*
* If there is no more authentication still being done,
* proceed to the network (or callback) phase.
*/
if ((auth_pending[unit] &= ~pbit) == 0)
network_phase(unit);
}
示例12: GC_free
/* Explicitly deallocate an object p. */
GC_API void GC_CALL GC_free(void * p)
{
struct hblk *h;
hdr *hhdr;
size_t sz; /* In bytes */
size_t ngranules; /* sz in granules */
void **flh;
int knd;
struct obj_kind * ok;
DCL_LOCK_STATE;
if (p == 0) return;
/* Required by ANSI. It's not my fault ... */
# ifdef LOG_ALLOCS
GC_log_printf("GC_free(%p) after GC #%lu\n",
p, (unsigned long)GC_gc_no);
# endif
h = HBLKPTR(p);
hhdr = HDR(h);
# if defined(REDIRECT_MALLOC) && \
(defined(GC_SOLARIS_THREADS) || defined(GC_LINUX_THREADS) \
|| defined(MSWIN32))
/* For Solaris, we have to redirect malloc calls during */
/* initialization. For the others, this seems to happen */
/* implicitly. */
/* Don't try to deallocate that memory. */
if (0 == hhdr) return;
# endif
GC_ASSERT(GC_base(p) == p);
sz = hhdr -> hb_sz;
ngranules = BYTES_TO_GRANULES(sz);
knd = hhdr -> hb_obj_kind;
ok = &GC_obj_kinds[knd];
if (EXPECT(ngranules <= MAXOBJGRANULES, TRUE)) {
LOCK();
GC_bytes_freed += sz;
if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= sz;
/* Its unnecessary to clear the mark bit. If the */
/* object is reallocated, it doesn't matter. O.w. the */
/* collector will do it, since it's on a free list. */
if (ok -> ok_init) {
BZERO((word *)p + 1, sz-sizeof(word));
}
flh = &(ok -> ok_freelist[ngranules]);
obj_link(p) = *flh;
*flh = (ptr_t)p;
UNLOCK();
} else {
size_t nblocks = OBJ_SZ_TO_BLOCKS(sz);
LOCK();
GC_bytes_freed += sz;
if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= sz;
if (nblocks > 1) {
GC_large_allocd_bytes -= nblocks * HBLKSIZE;
}
GC_freehblk(h);
UNLOCK();
}
}
示例13: ALLOC
/*----------------------------------------------------------------------*/
static ast_expression_t *parse_function_call(parse_state_t *p) {
token_t *token;
ast_expression_t *expression;
ast_expression_list_t *param, *new_param;
expression = ALLOC(sizeof(ast_expression_t));
BZERO(expression);
expression->tag = AST_EXPRESSION_FUNCTION_CALL;
/* function identifier */
token = next_token(p);
EXPECT(token, TK_IDENTIFIER, "function name expected");
expression->u.function_call.identifier = token;
/* opening bracket */
token = next_token(p);
EXPECT(token, TK_LBRACKET, "'(' expected");
/* parameter list */
param = NULL;
expression->u.function_call.parameter_count = 0;
for (;;) {
token = peek_token(p);
if (test_token(token, TK_RBRACKET))
break;
/* parameter */
new_param = ALLOC(sizeof(ast_expression_list_t));
new_param->next = NULL;
new_param->expr = parse_logical_expression(p);
if (new_param->expr == NULL)
error(p, "expression expected");
if (param == NULL) {
expression->u.function_call.parameter_expr_list = new_param;
} else {
param->next = new_param;
}
param = new_param;
expression->u.function_call.parameter_count += 1;
/* comma? */
token = peek_token(p);
if (test_token(token, TK_RBRACKET))
break;
if (test_token(token, TK_COMMA)) {
next_token(p);
continue;
}
error(p, "',' or ')' expected");
}
/* closing bracket */
token = next_token(p);
EXPECT(token, TK_RBRACKET, "')' expected");
return expression;
}
示例14: GC_build_fl
/* we have not yet allocated. */
GC_INNER ptr_t GC_build_fl(struct hblk *h, size_t sz, GC_bool clear,
ptr_t list)
{
word *p, *prev;
word *last_object; /* points to last object in new hblk */
/* Do a few prefetches here, just because its cheap. */
/* If we were more serious about it, these should go inside */
/* the loops. But write prefetches usually don't seem to */
/* matter much. */
PREFETCH_FOR_WRITE((ptr_t)h);
PREFETCH_FOR_WRITE((ptr_t)h + 128);
PREFETCH_FOR_WRITE((ptr_t)h + 256);
PREFETCH_FOR_WRITE((ptr_t)h + 378);
/* Handle small objects sizes more efficiently. For larger objects */
/* the difference is less significant. */
# ifndef SMALL_CONFIG
switch (sz) {
case 2: if (clear) {
return GC_build_fl_clear2(h, list);
} else {
return GC_build_fl2(h, list);
}
case 4: if (clear) {
return GC_build_fl_clear4(h, list);
} else {
return GC_build_fl4(h, list);
}
default:
break;
}
# endif /* !SMALL_CONFIG */
/* Clear the page if necessary. */
if (clear) BZERO(h, HBLKSIZE);
/* Add objects to free list */
p = (word *)(h -> hb_body) + sz; /* second object in *h */
prev = (word *)(h -> hb_body); /* One object behind p */
last_object = (word *)((char *)h + HBLKSIZE);
last_object -= sz;
/* Last place for last object to start */
/* make a list of all objects in *h with head as last object */
while (p <= last_object) {
/* current object's link points to last object */
obj_link(p) = (ptr_t)prev;
prev = p;
p += sz;
}
p -= sz; /* p now points to last object */
/*
* put p (which is now head of list of objects in *h) as first
* pointer in the appropriate free list for this size.
*/
obj_link(h -> hb_body) = list;
return ((ptr_t)p);
}
示例15: pciio_device_info_free
void
pciio_device_info_free(pciio_info_t pciio_info)
{
/* NOTE : pciio_info is a structure within the pcibr_info
* and not a pointer to memory allocated on the heap !!
*/
BZERO((char *)pciio_info,sizeof(pciio_info));
}