本文整理汇总了C++中p_free函数的典型用法代码示例。如果您正苦于以下问题:C++ p_free函数的具体用法?C++ p_free怎么用?C++ p_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例5: p_dclose
int
p_dclose(p_dir *dir)
{
int flag = closedir(dir->dir);
p_free(dir->dirname);
p_free(dir);
return flag;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}