本文整理汇总了C++中path_free函数的典型用法代码示例。如果您正苦于以下问题:C++ path_free函数的具体用法?C++ path_free怎么用?C++ path_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path_alloc_from_path
struct path *
path_alloc_from_path(struct path const *path)
{
if (!path) {
errno = EINVAL;
return NULL;
}
struct path *new_path = calloc(1, sizeof(struct path));
if (!new_path) return NULL;
new_path->is_absolute = path->is_absolute;
new_path->absolute = strdup(path->absolute);
if (!new_path->absolute) {
path_free(new_path);
return NULL;
}
new_path->given = strdup(path->given);
if (!new_path->given) {
path_free(new_path);
return NULL;
}
return new_path;
}
示例2: filesystem_get_url
static char filesystem_get_url(char const *path, char **url) {
path_t *path_parsed = path_parse(path);
if(path_parsed->parts_length != 2) {
pthread_mutex_unlock(filesystem_io_mutex);
path_free(path_parsed);
logging_log("Filesystem", LOGGING_LEVEL_WARNING,
"filesystem_get_url() - Invalid path %s...", path);
return -1;
}
pthread_mutex_lock(filesystem_io_mutex);
ALDictionary *results = searcher_get_search_results(path_parsed->parts[0]);
if(results == NULL) {
pthread_mutex_unlock(filesystem_io_mutex);
path_free(path_parsed);
logging_log("Filesystem", LOGGING_LEVEL_WARNING, "Invalid file %s...", path);
return -1;
}
char result;
*url = (char*)al_dictionary_get(results, &result, path_parsed->parts[1]);
pthread_mutex_unlock(filesystem_io_mutex);
if(result) {
logging_log("Filesystem", LOGGING_LEVEL_WARNING,
"filesystem_get_url() - Invalid path %s...", path);
return -1;
} else
logging_log("Filesystem", LOGGING_LEVEL_INFO, "filesystem_get_url() - Url is %s...", *url);
path_free(path_parsed);
return 0;
}
示例3: path_alloc
struct path *
path_alloc(char const *given_path, char const *working_directory)
{
if (!given_path) {
errno = EINVAL;
return NULL;
}
if (working_directory && '/' != working_directory[0]) {
errno = EINVAL;
return NULL;
}
// TODO: check that resulting path doesn't exceed MAXPATHLEN
struct path *path = calloc(1, sizeof(struct path));
if (!path) return NULL;
path->given = strdup(given_path);
if (!path->given) {
path_free(path);
return NULL;
}
if ('/' == given_path[0]) {
path->is_absolute = true;
path->absolute = strdup(given_path);
if (!path->absolute) {
path_free(path);
return NULL;
}
} else {
if (working_directory) {
int bytes_formatted = asprintf(&path->absolute, "%s/%s",
working_directory, given_path);
if (-1 == bytes_formatted) {
path_free(path);
return NULL;
}
} else {
char *cwd = getcwd(NULL, 0);
if (!cwd) {
path_free(path);
return NULL;
}
int bytes_formatted = asprintf(&path->absolute, "%s/%s",
cwd, given_path);
free(cwd);
if (-1 == bytes_formatted) {
path_free(path);
return NULL;
}
}
}
return path;
}
示例4: pkg_find
pkg_t *
pkg_find(const char *name, unsigned int flags)
{
char **path = NULL;
size_t count = 0, iter = 0;
const char *env_path;
pkg_t *pkg = NULL;
FILE *f;
/* name might actually be a filename. */
if (str_has_suffix(name, PKG_CONFIG_EXT))
{
if ((f = fopen(name, "r")) != NULL)
return pkg_new_from_file(name, f);
}
/* PKG_CONFIG_PATH has to take precedence */
env_path = getenv("PKG_CONFIG_PATH");
if (env_path)
{
count = path_split(env_path, &path);
for (iter = 0; iter < count; iter++)
{
pkg = pkg_try_specific_path(path[iter], name, flags);
if (pkg != NULL)
goto out;
}
path_free(path, count);
}
env_path = get_pkgconfig_path();
if (!(flags & PKGF_ENV_ONLY))
{
count = path_split(env_path, &path);
for (iter = 0; iter < count; iter++)
{
pkg = pkg_try_specific_path(path[iter], name, flags);
if (pkg != NULL)
goto out;
}
}
#ifdef _WIN32
/* support getting PKG_CONFIG_PATH from registry */
pkg = pkg_find_in_registry_key(HKEY_CURRENT_USER, name, flags);
if (!pkg)
pkg = pkg_find_in_registry_key(HKEY_LOCAL_MACHINE, name, flags);
#endif
out:
path_free(path, count);
return pkg;
}
示例5: predicate_free
static void predicate_free(predicate *value)
{
if(NULL == value)
{
return;
}
if(JOIN == predicate_kind(value))
{
path_free(value->join.left);
path_free(value->join.right);
}
free(value);
}
示例6: vh_scanner_uninit
void
vh_scanner_uninit (scanner_t *scanner)
{
vh_log (VALHALLA_MSG_VERBOSE, __FUNCTION__);
if (!scanner)
return;
vh_timer_thread_delete (scanner->timer);
if (scanner->paths)
path_free (scanner->paths);
if (scanner->suffix)
{
char **it;
for (it = scanner->suffix; *it; it++)
free (*it);
free (scanner->suffix);
}
vh_fifo_queue_free (scanner->fifo);
pthread_mutex_destroy (&scanner->mutex_run);
free (scanner);
}
示例7: START_TEST
END_TEST
START_TEST (absolute_multi_step)
{
char *expression = "$.foo.baz..yobble.thingum";
reset_errno();
parser_context *context = make_parser((uint8_t *)expression, strlen(expression));
assert_not_null(context);
assert_noerr();
jsonpath *path = parse(context);
assert_parser_success(expression, context, path, ABSOLUTE_PATH, 5);
assert_root_step(path);
assert_single_name_step(path, 1, "foo");
assert_single_name_step(path, 2, "baz");
assert_recursive_name_step(path, 3, "yobble");
assert_single_name_step(path, 4, "thingum");
assert_no_predicate(path, 1);
assert_no_predicate(path, 2);
assert_no_predicate(path, 3);
assert_no_predicate(path, 4);
path_free(path);
parser_free(context);
}
示例8: test_find_path_empty_level_horizontal
static char* test_find_path_empty_level_horizontal()
{
Level* level = level_alloc_empty(LEVEL_TEST_WIDTH, LEVEL_TEST_HEIGHT);
mu_assert(level != NULL);
Cell* start_cell = &level->cells[2][1];
Cell* target_cell = &level->cells[2][17];
Path* path = find_path(level, start_cell, target_cell);
mu_assert(path != NULL);
mu_assert(path->distance == 12 * (17 - 1));
mu_assert(path->step_count == 17);
mu_assert(path->steps != NULL);
mu_assert(test_is_path_start_and_end_step_correct(path, start_cell, target_cell));
mu_assert(test_is_path_walkable(path, level) == 1);
int i;
for (i = 1; i < path->step_count; i++)
{
mu_assert(path->steps[i].row == start_cell->row);
mu_assert(path->steps[i].col == start_cell->col + i);
}
path_free(path);
level_free(level);
return NULL;
}
示例9: word_free
void word_free(word_t* w){
if (w == NULL)
return;
free(w->word);
path_free(w->path);
free(w);
}
示例10: PRECOND_NONNULL_ELSE_NULL
jsonpath *parse(parser_context *context)
{
PRECOND_NONNULL_ELSE_NULL(context);
PRECOND_NONNULL_ELSE_NULL(context->path);
PRECOND_NONNULL_ELSE_NULL(context->input);
PRECOND_ELSE_NULL(0 != context->length);
debug_string("parsing expression: '%s'", context->input, context->length);
if(parse_expression(context))
{
parser_debug("done. found %zd steps.", context->path->length);
return context->path;
}
else
{
context->result.actual_char = context->input[context->cursor];
#ifdef USE_LOGGING
char *message = parser_status_message(context);
parser_error("aborted. unable to create jsonpath model. status: %d (%s)", context->result.code, message);
free(message);
#endif
path_free(context->path);
context->path = NULL;
return NULL;
}
}
示例11: entity_free
void entity_free(entity* ent){ //makes entity->inuse false so new ent can be initialized in this mem location
ent->inuse = false;
ent->sprite = NULL;
path_free(ent->path);
entity_count--;
}
示例12: pathlist_free
/* free a pathlist, leaving errno untouched. */
void pathlist_free( path_t* plist )
{
path_t* p;
list_forall_unlink( p, plist ) {
path_free( p );
}
示例13: test_find_path_empty_level_corner_to_corner
static char* test_find_path_empty_level_corner_to_corner()
{
Level* level = level_alloc_empty(LEVEL_TEST_WIDTH, LEVEL_TEST_HEIGHT);
mu_assert(level != NULL);
Cell* start_cell = &level->cells[11][0];
Cell* target_cell = &level->cells[0][24];
Path* path = find_path(level, start_cell, target_cell);
mu_assert(path != NULL);
mu_assert(path->distance == 12 * 13 + 17 * 11);
mu_assert(path->step_count == 25);
mu_assert(path->steps != NULL);
mu_assert(test_is_path_start_and_end_step_correct(path, start_cell, target_cell));
mu_assert(test_is_path_walkable(path, level) == 1);
int i;
for (i = 1; i < path->step_count - 1; i++)
{
mu_assert(path->steps[i].row <= start_cell->row);
mu_assert(path->steps[i].col >= start_cell->col);
mu_assert(path->steps[i].row >= target_cell->row);
mu_assert(path->steps[i].col <= target_cell->col);
}
path_free(path);
level_free(level);
return NULL;
}
示例14: audio_route_free
void audio_route_free(struct audio_route *ar)
{
free_mixer_state(ar);
mixer_close(ar->mixer);
path_free(ar);
free(ar);
ar = NULL;
}
示例15: advance_fileio_done
void advance_fileio_done(struct advance_fileio_context* context)
{
struct fileio_item* i;
for(i=FILEIO_CONFIG;i->type != FILETYPE_end;++i) {
path_free(i->dir_map, i->dir_mac);
}
if (context->state.diff_handle) {
fzclose(context->state.diff_handle);
}
}