• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ p_free函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: spawn_free

static void
spawn_free(void *vproc)
{
  if (vproc) {
    spawn_proc *proc = vproc;
    spawn_proc *list = spawn_list;
    char *argv0 = proc->argv0;
    p_spawn_t *pp = proc->proc;
    proc->argv0 = 0;
    proc->proc = 0;
    p_free(argv0);
    if (pp) {
      p_send(pp, (char *)0, -9);
      p_spawf(pp, 0);
    }
    if (list == proc) {
      spawn_list = proc->next;
    } else while (list && list->next) {
      if (list->next == proc) {
        list->next = proc->next;
        break;
      }
      list = list->next;
    }
    p_free(proc);
  }
}
开发者ID:MattWherry,项目名称:yorick,代码行数:27,代码来源:spawn.c


示例2: compare_socket_addresses

static pboolean compare_socket_addresses (const PSocketAddress *addr1, const PSocketAddress *addr2)
{
	if (addr1 == NULL || addr2 == NULL)
		return FALSE;

	pchar *addr_str1 = p_socket_address_get_address (addr1);
	pchar *addr_str2 = p_socket_address_get_address (addr2);

	if (addr_str1 == NULL || addr_str2 == NULL) {
		p_free (addr_str1);
		p_free (addr_str2);

		return FALSE;
	}

	pboolean addr_cmp = (strcmp (addr_str1, addr_str2) == 0 ? TRUE : FALSE);

	p_free (addr_str1);
	p_free (addr_str2);

	if (addr_cmp == FALSE)
		return FALSE;

	if (p_socket_address_get_family (addr1) != p_socket_address_get_family (addr2))
		return FALSE;

	if (p_socket_address_get_native_size (addr1) != p_socket_address_get_native_size (addr2))
		return FALSE;

	return TRUE;
}
开发者ID:saprykin,项目名称:plibsys,代码行数:31,代码来源:psocket_test.cpp


示例3: ufs_traverse_path

ufs_inode_t* ufs_traverse_path(ufs_t *mount, const char *_path)
{
    uint32_t i;
    uint32_t inum = 2; // 2 == root
    ufs_inode_t *inode = p_alloc(mount->pool, sizeof(ufs_inode_t));
    char *path = p_alloc(mount->pool, strlen(_path)+1);
    strcpy(path, _path);
    
    if (!ufs_load_inode(mount, inode, inum))
        goto fail;
    
    char *last, *elem;
    for (elem = strtok_r(path, "/", &last);
         elem;
         elem = strtok_r(NULL, "/", &last)) {
        
        uint32_t next_inum = 0;
        uint8_t *dir = ufs_read_inode_data(mount, inode);
        if (!dir)
            goto fail;
        
        for (i=0; inode->size; ) {
            ufs_dir_t *entry = (ufs_dir_t*)&dir[i];
            fix_endian(entry->inum);
            fix_endian(entry->len);
            fix_endian(entry->namelen);
            
            if (entry->inum == 0)
                break;
            
            if ((entry->namelen == strlen(elem)) &&
                (strncmp(elem, entry->name, entry->namelen) == 0)) {
                next_inum = entry->inum;
                break;
            }
            
            i += entry->len;
        }
        
        p_free(dir);
        
        if (next_inum == 0) {
            sprintf(mount->error_str, "'%s' in '%s' doesn't exist", elem, _path);
            goto fail;
        }
        
        inum = next_inum;
        if (!ufs_load_inode(mount, inode, inum))
            goto fail;
    }
    
    p_free(path);
    return inode;
    
fail:
    p_free(inode);
    p_free(path);
    return NULL;
}
开发者ID:OCForks,项目名称:shoebill,代码行数:59,代码来源:filesystem.c


示例4: GaFreeScratch

int GaFreeScratch(void)
{
  if (nScratchP>0) { p_free(gaxScratch);  p_free(gayScratch); }
  if (nScratchS>0) p_free(gasScratch);
  if (nScratch>0) { p_free(xScratch);   p_free(yScratch); }
  nScratchP= nScratchS= nScratch= 0;
  return 0;
}
开发者ID:MattWherry,项目名称:yorick,代码行数:8,代码来源:gist.c


示例5: p_dclose

int
p_dclose(p_dir *dir)
{
  int flag = closedir(dir->dir);
  p_free(dir->dirname);
  p_free(dir);
  return flag;
}
开发者ID:MattWherry,项目名称:yorick,代码行数:8,代码来源:dir.c


示例6: p_dir_new

P_LIB_API PDir *
p_dir_new (const pchar	*path,
	   PError	**error)
{
	PDir	*ret;
	pchar	*pathp;

	if (P_UNLIKELY (path == NULL)) {
		p_error_set_error_p (error,
				     (pint) P_ERROR_IO_INVALID_ARGUMENT,
				     0,
				     "Invalid input argument");
		return NULL;
	}

	if (P_UNLIKELY ((ret = p_malloc0 (sizeof (PDir))) == NULL)) {
		p_error_set_error_p (error,
				     (pint) P_ERROR_IO_NO_RESOURCES,
				     0,
				     "Failed to allocate memory for directory structure");
		return NULL;
	}

	if (P_UNLIKELY (!GetFullPathNameA (path, MAX_PATH, ret->path, NULL))) {
		p_error_set_error_p (error,
				     (pint) p_error_get_last_io (),
				     p_error_get_last_system (),
				     "Failed to call GetFullPathNameA() to get directory path");
		p_free (ret);
		return NULL;
	}

	/* Append the search pattern "\\*\0" to the directory name */
	pathp = strchr (ret->path, '\0');

	if (ret->path < pathp  &&  *(pathp - 1) != '\\'  &&  *(pathp - 1) != ':')
		*pathp++ = '\\';

	*pathp++ = '*';
	*pathp = '\0';

	/* Open directory stream and retrieve the first entry */
	ret->search_handle = FindFirstFileA (ret->path, &ret->find_data);

	if (P_UNLIKELY (ret->search_handle == INVALID_HANDLE_VALUE)) {
		p_error_set_error_p (error,
				     (pint) p_error_get_last_io (),
				     p_error_get_last_system (),
				     "Failed to call FindFirstFileA() to open directory stream");
		p_free (ret);
		return NULL;
	}

	ret->cached    = TRUE;
	ret->orig_path = p_strdup (path);

	return ret;
}
开发者ID:saprykin,项目名称:plibsys,代码行数:58,代码来源:pdir-win.c


示例7: buffer_free

void buffer_free(buffer_t **_buf)
{
	struct real_buffer *buf = (struct real_buffer *)*_buf;

	*_buf = NULL;
	if (buf->alloced)
		p_free(buf->pool, buf->w_buffer);
	if (buf->pool != NULL)
		p_free(buf->pool, buf);
}
开发者ID:jwm,项目名称:dovecot-notmuch,代码行数:10,代码来源:buffer.c


示例8: ClearPrefixes

static void ClearPrefixes(void)
{
  int i, n= nYpPrefixes;
  char **prefixes= ypPrefixes;
  nYpPrefixes= 0;
  for (i=0 ; i<n ; i++) p_free(prefixes[i]);
  maxYpPrefixes= 0;
  ypPrefixes= 0;
  p_free(prefixes);
}
开发者ID:dhmunro,项目名称:yorick,代码行数:10,代码来源:yinput.c


示例9: p_error_free

P_LIB_API void
p_error_free (PError	*error)
{
	if (P_UNLIKELY (error == NULL))
		return;

	if (error->message != NULL)
		p_free (error->message);

	p_free (error);
}
开发者ID:shadowmint,项目名称:rust-plibsys-sys,代码行数:11,代码来源:perror.c


示例10: ufs_load_inode

static uint8_t ufs_load_inode(ufs_t *mount, ufs_inode_t *inode, uint32_t inum)
{
    assert(sizeof(ufs_inode_t) == 128);
    
    /* Which cylinder group is this inode in? */
    const uint32_t group_num = inum / mount->superblock.ipg;
    
    /* Index of this inode in its cylinder group's inode table */
    const uint32_t group_ino_offset = inum % mount->superblock.ipg;
    
    /* Fragment address that contains inode */
    const uint32_t frag_addr = ufs_group_base(mount, group_num) +
                               mount->superblock.iblkno +
                               ((group_ino_offset * 128) / mount->frag_size);
    
    /* Byte offset into the fragment where the inode begins */
    const uint32_t frag_offset = (group_ino_offset * 128) % mount->frag_size;
    
    uint32_t i;
    uint8_t *buf = p_alloc(mount->pool, mount->frag_size);
    
    // slog("group_num = %u, ino_offset=%u, addr = 0x%08x, offset = 0x%08x\n", group_num, group_ino_offset, frag_addr, frag_offset);
    // slog("mount->superblock.iblkno = 0x%08x\n", mount->superblock.iblkno);
    
    if (!ufs_read_frag(mount, buf, frag_addr))
        goto fail;
    
    memcpy(inode, buf + frag_offset, 128);
    
    fix_endian(inode->mode);
    fix_endian(inode->nlink);
    fix_endian(inode->uid);
    fix_endian(inode->gid);
    fix_endian(inode->size_hi);
    fix_endian(inode->size);
    fix_endian(inode->atime);
    fix_endian(inode->mtime);
    fix_endian(inode->ctime);
    for (i=0; i<12; i++)
        fix_endian(inode->direct[i]);
    for (i=0; i<3; i++)
        fix_endian(inode->indirect[i]);
    fix_endian(inode->flags);
    fix_endian(inode->blocks);
    fix_endian(inode->gen);
    
    p_free(buf);
    return 1;
fail:
    if (buf)
        p_free(buf);
    return 0;
}
开发者ID:OCForks,项目名称:shoebill,代码行数:53,代码来源:filesystem.c


示例11: dcrypt_gnutls_ctx_sym_set_key_iv_random

static
void dcrypt_gnutls_ctx_sym_set_key_iv_random(struct dcrypt_context_symmetric *ctx)
{
	if(ctx->key.data != NULL) p_free(ctx->pool, ctx->key.data);
	if(ctx->iv.data != NULL) p_free(ctx->pool, ctx->iv.data);
	ctx->key.data = p_malloc(ctx->pool, gnutls_cipher_get_key_size(ctx->cipher));
	random_fill(ctx->key.data, gnutls_cipher_get_key_size(ctx->cipher));
	ctx->key.size = gnutls_cipher_get_key_size(ctx->cipher);
	ctx->iv.data = p_malloc(ctx->pool, gnutls_cipher_get_iv_size(ctx->cipher));
	random_fill(ctx->iv.data, gnutls_cipher_get_iv_size(ctx->cipher));
	ctx->iv.size = gnutls_cipher_get_iv_size(ctx->cipher);
}
开发者ID:bdraco,项目名称:core,代码行数:12,代码来源:dcrypt-gnutls.c


示例12: svfs_read_inode_data

static uint8_t* svfs_read_inode_data(svfs_t *mount, svfs_inode_t *inode)
{
    uint8_t *tmp = p_alloc(mount->pool, mount->blocksize);
    uint8_t *buf = p_alloc(mount->pool, inode->size);
    uint32_t i, len = 0;
    
    // The first 10 block pointers in the inode point to data
    // The addr[10] is a L1 block pointer, [11] is L2, and [12] is L3
    for (i=0; (len < inode->size) && (i < 10); i++) {
        uint32_t chunk_size = inode->size - len;
        if (chunk_size > mount->blocksize)
            chunk_size = mount->blocksize;
        
        if (!svfs_read_block(mount, tmp, inode->addr[i])) {
            sprintf(mount->error_str, "couldn't read svfs block num %u at L0", inode->addr[i]);
            goto fail;
        }
        
        memcpy(buf + len, tmp, chunk_size);
        len += chunk_size;
    }
    
    
    if (!svfs_read_block(mount, tmp, inode->addr[10])) {
        sprintf(mount->error_str, "couldn't read svfs L1 block ptr %u", inode->addr[10]);
        goto fail;
    }
    else if (!svfs_read_level(mount, inode, buf, &len, (uint32_t*)tmp, 1))
        goto fail;
    
    if (!svfs_read_block(mount, tmp, inode->addr[11])) {
        sprintf(mount->error_str, "couldn't read svfs L2 block ptr %u", inode->addr[11]);
        goto fail;
    }
    else if (!svfs_read_level(mount, inode, buf, &len, (uint32_t*)tmp, 2))
        goto fail;
    
    if (!svfs_read_block(mount, tmp, inode->addr[12])) {
        sprintf(mount->error_str, "couldn't read svfs L3 block ptr %u", inode->addr[12]);
        goto fail;
    }
    else if (!svfs_read_level(mount, inode, buf, &len, (uint32_t*)tmp, 3))
        goto fail;
    
    p_free(tmp);
    return buf;
    
fail:
    p_free(tmp);
    p_free(buf);
    return NULL;
}
开发者ID:OCForks,项目名称:shoebill,代码行数:52,代码来源:filesystem.c


示例13: p_shm_free

P_LIB_API void
p_shm_free (PShm *shm)
{
	if (P_UNLIKELY (shm == NULL))
		return;

	pp_shm_clean_handle (shm);

	if (P_LIKELY (shm->platform_key != NULL))
		p_free (shm->platform_key);

	p_free (shm);
}
开发者ID:saprykin,项目名称:plibsys,代码行数:13,代码来源:pshm-win.c


示例14: ClearList

static void ClearList(void)
{
  void *item, **list= memlist;
  if (list) {
    while (nlist>0) {
      item= list[--nlist];
      list[nlist]= 0;
      if (item) p_free(item);
    }
    memlist= 0;
    p_free(list);
  }
  keeplist= 0;
}
开发者ID:dhmunro,项目名称:yorick,代码行数:14,代码来源:fortrn.c


示例15: hash_table_destroy

void hash_table_destroy(struct hash_table **_table)
{
	struct hash_table *table = *_table;

	*_table = NULL;

	if (!table->node_pool->alloconly_pool) {
		hash_table_destroy_nodes(table);
		destroy_node_list(table, table->free_nodes);
	}

	p_free(table->table_pool, table->nodes);
	p_free(table->table_pool, table);
}
开发者ID:via,项目名称:dovecot-clouddb,代码行数:14,代码来源:hash.c


示例16: p_dir_free

P_LIB_API void
p_dir_free (PDir *dir)
{
	if (dir == NULL)
		return;

	if (P_LIKELY (dir->search_handle != INVALID_HANDLE_VALUE)) {
		if (P_UNLIKELY (!FindClose (dir->search_handle)))
			P_ERROR ("PDir::p_dir_free: FindClose() failed");
	}

	p_free (dir->orig_path);
	p_free (dir);
}
开发者ID:saprykin,项目名称:plibsys,代码行数:14,代码来源:pdir-win.c


示例17: ClearParser

static void ClearParser(void *func)
{
  long i;
  extern int yp_continue;
  yp_continue = 0;
  HashClear(&literalTable);  /* sets literalTable.maxItems==0 */
  p_free(literalTypes);
  literalTypes= 0;

  reparsing= func;
  nYpReList= 0;
  p_free(ypReList);
  ypReList= 0;

  for (i=0 ; i<nConstants ; i++)
    if (constantTable[i].ops==&dataBlockSym) Unref(constantTable[i].value.db);
  nConstants= maxConstants= 0;
  p_free(constantTable);
  constantTable= 0;

  nextPC= 0;
  if (vmCodeSize > 1024L) vmCodeSize= 0;  /* force realloc */
  else memset(vmCode, 0, sizeof(Instruction)*vmCodeSize);

  previousOp= 0;

  wasUndecided= 0;

  nVariableRefs= nConstantRefs= nGotoTargets= 0;
  if (maxVariableRefs > 256L) maxVariableRefs= 0;  /* force realloc */
  if (maxConstantRefs > 256L) maxConstantRefs= 0;  /* force realloc */
  if (maxGotoTargets > 256L) maxGotoTargets= 0;  /* force realloc */

  nPos= nKey= nLocal= nTarget= 0;
  hasPosList= 0;
  stackDepth= maxStackDepth= didMaxDepth= 0;

  nextInc= 0;
  if (incCodeSize > 64L) incCodeSize= 0;  /* force realloc */

  loopDepth= 0;

  nextBSP= 0;
  if (breakStackSize > 16L) breakStackSize= 0;  /* force realloc */

  nMatrixMarkers= 0;
  if (maxMatrixMarkers > 16L) maxMatrixMarkers= 0;  /* force realloc */

  insideFunc= 0;
}
开发者ID:MattWherry,项目名称:yorick,代码行数:50,代码来源:parse.c


示例18: open_include

static p_file *PushInclude(const char *filename, int fullparse)
{
  p_file *file= 0;
  char *name= 0;
  long i;

  if (YIsAbsolute(filename)) {
    /* absolute pathname doesn't need any prefix */
    file= open_include(filename, fullparse);
    if (!file) return 0;
    name= p_strcpy(filename);

  } else {
    char *tmp;
    for (i=0 ; i<=nYpPrefixes ; i++) {
      if (i<nYpPrefixes) {
        tmp= p_strncat(ypPrefixes[i], filename, 0);
        name= YExpandName(tmp);
        p_free(tmp);
      } else {
        /* this branch is probably a bug --
         * if . is not on path probably should not find file...
         * maybe protects against empty path?
         */
        name= YExpandName(filename);
        if (!YIsAbsolute(name)) break;
      }
      file= open_include(name, fullparse);
      if (file) break;
      p_free(name);
    }
    if (!file) return 0;
  }

  if (nYpIncludes>=maxYpIncludes) {
    int newSize= maxYpIncludes+4;
    ypIncludes= p_realloc(ypIncludes, sizeof(IncludeFile)*newSize);
    maxYpIncludes= newSize;
  }

  if (fullparse) ClearSourceList(name);

  ypIncludes[nYpIncludes].file= file;
  ypIncludes[nYpIncludes].filename= name;
  ypIncludes[nYpIncludes].lastLineRead= 0;
  ypIncludes[nYpIncludes++].index = -1;
  prevErrLine= -1;
  return file;
}
开发者ID:dhmunro,项目名称:yorick,代码行数:49,代码来源:yinput.c


示例19: p_dir_free

P_LIB_API void
p_dir_free (PDir *dir)
{
	if (P_UNLIKELY (dir == NULL))
		return;

	if (P_LIKELY (dir->dir != NULL)) {
		if (P_UNLIKELY (closedir (dir->dir) != 0))
			P_ERROR ("PDir::p_dir_free: closedir() failed");
	}

	p_free (dir->path);
	p_free (dir->orig_path);
	p_free (dir);
}
开发者ID:saprykin,项目名称:plibsys,代码行数:15,代码来源:pdir-posix.c


示例20: p_hash_table_remove

P_LIB_API void
p_hash_table_remove (PHashTable *table, pconstpointer key)
{
	PHashTableNode	*node, *prev_node;
	puint		hash;

	if (P_UNLIKELY (table == NULL))
		return;

	if (pp_hash_table_find_node (table, key) != NULL) {
		hash = pp_hash_table_calc_hash (key, table->size);
		node = table->table[hash];
		prev_node = NULL;

		while (node != NULL) {
			if (node->key == key) {
				if (prev_node == NULL)
					table->table[hash] = node->next;
				else
					prev_node->next = node->next;

				p_free (node);
				break;
			} else {
				prev_node = node;
				node = node->next;
			}
		}
	}
}
开发者ID:saprykin,项目名称:plibsys,代码行数:30,代码来源:phashtable.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ p_get_proto_data函数代码示例发布时间:2022-05-30
下一篇:
C++ p_error函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap