本文整理汇总了C++中FREENULL函数的典型用法代码示例。如果您正苦于以下问题:C++ FREENULL函数的具体用法?C++ FREENULL怎么用?C++ FREENULL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FREENULL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ParseURL
/*****************************************************************************
* ParseURL : Split an http:// URL into host, path, and port
*
* Example: "62.216.251.205:80/protocol_1.2"
* will be split into "62.216.251.205", 80, "protocol_1.2"
*
* psz_url will be freed before returning
* *psz_file & *psz_host will be freed before use
*
* Return value:
* VLC_ENOMEM Out Of Memory
* VLC_EGENERIC Invalid url provided
* VLC_SUCCESS Success
*****************************************************************************/
int ParseURL(char* url, char** host, char** path, int* port)
{
unsigned char port_given = 0,
path_given = 0;
if(url == NULL)
return -1;
FREENULL(*host);
FREENULL(*path);
if(strstr(url, "http://") == url)
{
url = url + 7;
}
size_t port_separator_position = strcspn(url, ":");
size_t path_separator_position = strcspn(url, "/");
if(port_separator_position != strlen(url))
{
port_given = 1;
*host = strndup(url, port_separator_position);
if(*host == NULL)
return VLC_ENOMEM;
}
if(path_separator_position != strlen(url))
{
path_given = 1;
if(!port_given)
{
*host = strndup(url, path_separator_position);
if(*host == NULL)
return VLC_ENOMEM;
}
}
if(port_given)
{
*port = atoi(url + port_separator_position + 1);
*host = strndup(url, port_separator_position);
if(*host == NULL)
return VLC_ENOMEM;
} else {
*port = 80;
}
if(path_given)
{
*path = strdup(url + path_separator_position + 1);
} else {
*path = strdup("/");
}
if(*path == NULL)
return VLC_ENOMEM;
return VLC_SUCCESS;
}
开发者ID:watchedit,项目名称:vlc-module,代码行数:74,代码来源:scrobbler.c
示例2: DeleteSong
/*****************************************************************************
* DeleteSong : Delete the char pointers in a song
*****************************************************************************/
static void DeleteSong(audioscrobbler_song_t* p_song)
{
FREENULL(p_song->psz_a);
FREENULL(p_song->psz_b);
FREENULL(p_song->psz_t);
FREENULL(p_song->psz_m);
FREENULL(p_song->psz_n);
}
开发者ID:Kubink,项目名称:vlc,代码行数:11,代码来源:audioscrobbler.c
示例3: journal_pack
void journal_pack( journal_t *journal, char **packed, size_t *size )
{
char *packed_journal_header = NULL;
size_t packed_journal_header_size = 0;
char *packed_channel = NULL;
size_t packed_channel_size = 0;
char *packed_channel_buffer = NULL;
size_t packed_channel_buffer_size = 0;
char *p = NULL;
int i = 0;
*packed = NULL;
*size = 0;
if( ! journal ) return;
logging_printf( LOGGING_DEBUG, "journal_pack: journal_has_data = %s header->totchan=%u\n", ( journal_has_data( journal ) ? "YES" : "NO" ) , journal->header->totchan);
if( ! journal_has_data( journal ) ) return;
journal_header_pack( journal->header, &packed_journal_header, &packed_journal_header_size );
for( i = 0 ; i < MAX_MIDI_CHANNELS ; i++ )
{
if( ! journal->channels[i] ) continue;
channel_pack( journal->channels[i], &packed_channel, &packed_channel_size );
packed_channel_buffer = ( char * )realloc( packed_channel_buffer, packed_channel_buffer_size + packed_channel_size );
if( ! packed_channel_buffer ) goto journal_pack_cleanup;
p = packed_channel_buffer + packed_channel_buffer_size;
memset( p, 0, packed_channel_size );
packed_channel_buffer_size += packed_channel_size;
memcpy( p, packed_channel, packed_channel_size );
FREENULL( "packed_channel", (void **)&packed_channel );
}
// Join it all together
*packed = ( char * )malloc( packed_journal_header_size + packed_channel_buffer_size );
p = *packed;
memcpy( p, packed_journal_header, packed_journal_header_size );
*size += packed_journal_header_size;
p += packed_journal_header_size;
memcpy( p, packed_channel_buffer, packed_channel_buffer_size );
*size += packed_channel_buffer_size;
journal_pack_cleanup:
FREENULL( "packed_channel", (void **)&packed_channel );
FREENULL( "packed_channel_buffer", (void **)&packed_channel_buffer );
FREENULL( "packed_journal_header", (void **)&packed_journal_header );
}
开发者ID:ravelox,项目名称:pimidi,代码行数:55,代码来源:midi_journal.c
示例4: sms_queue_free
void sms_queue_free( sms_queue_t* queue )
{
item_t *item = queue->first, *next = NULL;
while( item )
{
next = item->next;
FREENULL( item );
item = next;
}
FREENULL( queue );
}
开发者ID:WutongEdward,项目名称:vlc-2.1.4.32.subproject-2013,代码行数:11,代码来源:utils.c
示例5: midi_payload_destroy
void midi_payload_destroy( midi_payload_t **payload )
{
if( ! payload ) return;
if( ! *payload ) return;
(*payload)->buffer = NULL;
if( (*payload)->header )
{
FREENULL( (void **)&((*payload)->header) );
}
FREENULL( (void **)payload );
}
开发者ID:ViktorNova,项目名称:pimidi,代码行数:14,代码来源:midi_payload.c
示例6: VCDClose
/*****************************************************************************
* VCDClose: closes VCD releasing allocated memory.
*****************************************************************************/
void
VCDClose ( vlc_object_t *p_this )
{
access_t *p_access = (access_t *)p_this;
vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_access->p_sys;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "VCDClose" );
{
unsigned int i;
for (i=0 ; i<p_vcdplayer->i_titles; i++)
if (p_vcdplayer->p_title[i])
free(p_vcdplayer->p_title[i]->psz_name);
}
vcdinfo_close( p_vcdplayer->vcd );
if( p_vcdplayer->p_input ) vlc_object_release( p_vcdplayer->p_input );
FREENULL( p_vcdplayer->p_entries );
FREENULL( p_vcdplayer->p_segments );
FREENULL( p_vcdplayer->psz_source );
FREENULL( p_vcdplayer->track );
FREENULL( p_vcdplayer->segment );
FREENULL( p_vcdplayer->entry );
FREENULL( p_access->psz_demux );
FREENULL( p_vcdplayer );
p_vcd_access = NULL;
}
开发者ID:BtbN,项目名称:vlc,代码行数:32,代码来源:access.c
示例7: config_ChainDestroy
void config_ChainDestroy( config_chain_t *p_cfg )
{
while( p_cfg != NULL )
{
config_chain_t *p_next;
p_next = p_cfg->p_next;
FREENULL( p_cfg->psz_name );
FREENULL( p_cfg->psz_value );
free( p_cfg );
p_cfg = p_next;
}
}
开发者ID:0xheart0,项目名称:vlc,代码行数:15,代码来源:chain.c
示例8: ParseURL
/*****************************************************************************
* ParseURL : Split an http:// URL into host, file, and port
*
* Example: "62.216.251.205:80/protocol_1.2"
* will be split into "62.216.251.205", 80, "protocol_1.2"
*
* psz_url will be freed before returning
* *psz_file & *psz_host will be freed before use
*
* Return value:
* VLC_ENOMEM Out Of Memory
* VLC_EGENERIC Invalid url provided
* VLC_SUCCESS Success
*****************************************************************************/
static int ParseURL( char *psz_url, char **psz_host, char **psz_file,
int *i_port )
{
int i_pos;
int i_len = strlen( psz_url );
bool b_no_port = false;
FREENULL( *psz_host );
FREENULL( *psz_file );
i_pos = strcspn( psz_url, ":" );
if( i_pos == i_len )
{
*i_port = 80;
i_pos = strcspn( psz_url, "/" );
b_no_port = true;
}
*psz_host = strndup( psz_url, i_pos );
if( !*psz_host )
return VLC_ENOMEM;
if( !b_no_port )
{
i_pos++; /* skip the ':' */
*i_port = atoi( psz_url + i_pos );
if( *i_port <= 0 )
{
FREENULL( *psz_host );
return VLC_EGENERIC;
}
i_pos = strcspn( psz_url, "/" );
}
if( i_pos == i_len )
return VLC_EGENERIC;
i_pos++; /* skip the '/' */
*psz_file = strdup( psz_url + i_pos );
if( !*psz_file )
{
FREENULL( *psz_host );
return VLC_ENOMEM;
}
free( psz_url );
return VLC_SUCCESS;
}
开发者ID:Italianmoose,项目名称:Stereoscopic-VLC,代码行数:62,代码来源:audioscrobbler.c
示例9: sms_queue_put
int sms_queue_put( sms_queue_t *queue, const uint64_t value )
{
/* Remove the last (and oldest) item */
item_t *item, *prev = NULL;
int count = 0;
for( item = queue->first; item != NULL; item = item->next )
{
count++;
if( count == queue->length )
{
FREENULL( item );
if( prev ) prev->next = NULL;
break;
}
else
prev = item;
}
/* Now insert the new item */
item_t *_new = (item_t *)malloc( sizeof( item_t ) ); // sunqueen modify
if( unlikely( !_new ) ) // sunqueen modify
return VLC_ENOMEM;
_new->value = value; // sunqueen modify
_new->next = queue->first; // sunqueen modify
queue->first = _new; // sunqueen modify
return VLC_SUCCESS;
}
开发者ID:WutongEdward,项目名称:vlc-2.1.4.32.subproject-2013,代码行数:29,代码来源:utils.c
示例10: MYDEBUG
bool cDVDList::Create(char *dir, char *exts, char *dirs, eFileList smode, bool sub)
{
MYDEBUG("DVDList: %s, %s", exts, dirs);
Clear();
FREENULL(DVDExts);
FREENULL(DVDDirs);
DVDExts = exts ? strdup(exts) : NULL;
DVDDirs = dirs ? strdup(dirs) : NULL;
if(!DVDExts && !DVDDirs)
return false;
return Load(dir, smode, sub);
}
开发者ID:suborb,项目名称:reelvdr,代码行数:16,代码来源:dvdlist.c
示例11: channel_destroy
void channel_destroy( channel_t **channel )
{
if( ! channel ) return;
if( ! *channel ) return;
if( (*channel)->chapter_n )
{
chapter_n_destroy( &( (*channel)->chapter_n ) );
}
if( (*channel)->chapter_c )
{
chapter_c_destroy( &( (*channel)->chapter_c ) );
}
if( (*channel)->chapter_p )
{
chapter_p_destroy( &( (*channel)->chapter_p ) );
}
if( (*channel)->header )
{
channel_header_destroy( &( (*channel)->header ) );
}
FREENULL("channel", (void **) channel);
}
开发者ID:ravelox,项目名称:pimidi,代码行数:28,代码来源:midi_journal.c
示例12: gotoNextChunk
static chunk_t * gotoNextChunk( stream_sys_t *p_sys )
{
assert(p_sys->p_current_stream);
chunk_t *p_prev = p_sys->p_current_stream->p_playback;
if ( p_prev )
{
if ( p_sys->b_live )
{
/* Discard chunk and update stream pointers */
assert( p_sys->p_current_stream->p_chunks == p_sys->p_current_stream->p_playback );
p_sys->p_current_stream->p_playback = p_sys->p_current_stream->p_playback->p_next;
p_sys->p_current_stream->p_chunks = p_sys->p_current_stream->p_chunks->p_next;
if ( p_sys->p_current_stream->p_lastchunk == p_prev )
p_sys->p_current_stream->p_lastchunk = NULL;
chunk_Free( p_prev );
}
else
{
/* Just cleanup chunk for reuse on seek */
p_sys->p_current_stream->p_playback = p_sys->p_current_stream->p_playback->p_next;
FREENULL(p_prev->data);
p_prev->read_pos = 0;
p_prev->offset = CHUNK_OFFSET_UNSET;
p_prev->size = 0;
}
}
/* Select new current pointer among streams playback heads */
p_sys->p_current_stream = next_playback_stream( p_sys );
if ( !p_sys->p_current_stream )
return NULL;
return p_sys->p_current_stream->p_playback;
}
开发者ID:xswm1123,项目名称:vlc,代码行数:34,代码来源:smooth.c
示例13: strdup
char *cFileInfo::FileNameWithoutExt(void)
{
char *ext = NULL;
char *filename = NULL;
if(Extension())
ext = strdup(Extension());
if(FileName())
filename = strdup(FileName());
FREENULL(buffer);
if(ext && filename)
{
int len = strlen(filename) - strlen(ext) + 1;
buffer = (char*)malloc(len);
strn0cpy(buffer, filename, len);
}
else if(filename)
buffer = strdup(filename);
free(ext);
free(filename);
MYDEBUG("FileInfo: FileNameWithoutExt: %s", buffer);
return buffer;
}
开发者ID:suborb,项目名称:reelvdr,代码行数:28,代码来源:helpers.c
示例14: Dir
bool cFileList::Read(char *dir, bool withsub)
{
bool ret = false;
char *buffer = NULL;
struct dirent *DirData = NULL;
cReadDir Dir(dir);
if(Dir.Ok())
{
while((DirData = Dir.Next()) != NULL)
{
if(CheckIncludes(dir, DirData->d_name) &&
!CheckExcludes(dir, DirData->d_name) &&
CheckType(dir, DirData->d_name, Type))
SortIn(dir, DirData->d_name);
if(withsub &&
CheckType(dir, DirData->d_name, tDir) &&
!RegIMatch(DirData->d_name, "^\\.{1,2}$"))
{
asprintf(&buffer, "%s/%s", dir, DirData->d_name);
Read(buffer, withsub);
FREENULL(buffer);
}
}
ret = true;
}
return ret;
}
开发者ID:suborb,项目名称:reelvdr,代码行数:30,代码来源:helpers.c
示例15: DemuxGenre
/* <genrelist>
* <genre name="the name"></genre>
* ...
* </genrelist>
**/
static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
input_item_node_t *p_input_node )
{
const char *node;
char *psz_name = NULL; /* genre name */
int type;
while( (type = xml_ReaderNextNode( p_xml_reader, &node )) > 0 )
{
switch( type )
{
case XML_READER_STARTELEM:
{
if( !strcmp( node, "genre" ) )
{
// Read the attributes
const char *name, *value;
while( (name = xml_ReaderNextAttr( p_xml_reader, &value )) )
{
if( !strcmp( name, "name" ) )
{
free(psz_name);
psz_name = strdup( value );
}
else
msg_Warn( p_demux,
"unexpected attribute %s in <%s>",
name, node );
}
}
break;
}
case XML_READER_ENDELEM:
if( !strcmp( node, "genre" ) && psz_name != NULL )
{
char* psz_mrl;
if( asprintf( &psz_mrl, SHOUTCAST_BASE_URL "?genre=%s",
psz_name ) != -1 )
{
input_item_t *p_input;
vlc_xml_decode( psz_mrl );
p_input = input_item_New( psz_mrl, psz_name );
input_item_CopyOptions( p_input_node->p_item, p_input );
free( psz_mrl );
input_item_node_AppendItem( p_input_node, p_input );
vlc_gc_decref( p_input );
}
FREENULL( psz_name );
}
break;
}
}
free( psz_name );
return 0;
}
开发者ID:qdk0901,项目名称:vlc,代码行数:63,代码来源:shoutcast.c
示例16: http_auth_Reset
void http_auth_Reset( http_auth_t *p_auth )
{
p_auth->i_nonce = 0;
FREENULL( p_auth->psz_realm );
FREENULL( p_auth->psz_domain );
FREENULL( p_auth->psz_nonce );
FREENULL( p_auth->psz_opaque );
FREENULL( p_auth->psz_stale );
FREENULL( p_auth->psz_algorithm );
FREENULL( p_auth->psz_qop );
FREENULL( p_auth->psz_cnonce );
FREENULL( p_auth->psz_HA1 );
}
开发者ID:vlcchina,项目名称:vlc-player-experimental,代码行数:14,代码来源:http_auth.c
示例17: cleanup_attributes
static void cleanup_attributes(custom_attrs_t **cp)
{
if( !*cp )
return;
free( (*cp)->psz_key );
free( (*cp)->psz_value );
FREENULL( *cp );
}
开发者ID:xswm1123,项目名称:vlc,代码行数:9,代码来源:smooth.c
示例18: Run
static void Run( fingerprinter_thread_t *p_fingerprinter )
{
fingerprinter_sys_t *p_sys = p_fingerprinter->p_sys;
/* main loop */
for (;;)
{
vlc_mutex_lock( &p_sys->processing.lock );
mutex_cleanup_push( &p_sys->processing.lock );
vlc_cond_timedwait( &p_sys->incoming_queue_filled, &p_sys->processing.lock, mdate() + 1000000 );
vlc_cleanup_run();
QueueIncomingRequests( p_sys );
vlc_mutex_lock( &p_sys->processing.lock ); // L0
mutex_cleanup_push( &p_sys->processing.lock );
vlc_cleanup_push( cancelRun, p_sys ); // C1
//**
for ( p_sys->i = 0 ; p_sys->i < vlc_array_count( p_sys->processing.queue ); p_sys->i++ )
{
fingerprint_request_t *p_data = vlc_array_item_at_index( p_sys->processing.queue, p_sys->i );
acoustid_fingerprint_t acoustid_print;
memset( &acoustid_print , 0, sizeof(acoustid_fingerprint_t) );
vlc_cleanup_push( clearPrint, &acoustid_print ); // C2
p_sys->psz_uri = input_item_GetURI( p_data->p_item );
if ( p_sys->psz_uri )
{
/* overwrite with hint, as in this case, fingerprint's session will be truncated */
if ( p_data->i_duration ) acoustid_print.i_duration = p_data->i_duration;
DoFingerprint( VLC_OBJECT(p_fingerprinter), p_sys, &acoustid_print );
DoAcoustIdWebRequest( VLC_OBJECT(p_fingerprinter), &acoustid_print );
fill_metas_with_results( p_data, &acoustid_print );
FREENULL( p_sys->psz_uri );
}
vlc_cleanup_run( ); // C2
/* copy results */
vlc_mutex_lock( &p_sys->results.lock );
vlc_array_append( p_sys->results.queue, p_data );
vlc_mutex_unlock( &p_sys->results.lock );
vlc_testcancel();
}
if ( vlc_array_count( p_sys->processing.queue ) )
{
var_TriggerCallback( p_fingerprinter, "results-available" );
vlc_array_clear( p_sys->processing.queue );
}
vlc_cleanup_pop( ); // C1
//**
vlc_cleanup_run(); // L0
}
}
开发者ID:Kubink,项目名称:vlc,代码行数:56,代码来源:fingerprinter.c
示例19: calloc
static http_cookie_t *cookie_parse(const char *value,
const char *host, const char *path)
{
http_cookie_t *cookie = calloc( 1, sizeof( http_cookie_t ) );
if ( unlikely( !cookie ) )
return NULL;
char *content = cookie_get_content(value);
if ( !content )
{
cookie_destroy( cookie );
return NULL;
}
const char *eq = strchr( content, '=' );
if ( eq )
{
cookie->psz_name = strndup( content, eq-content );
cookie->psz_value = strdup( eq + 1 );
}
else
{
cookie->psz_name = strdup( content );
cookie->psz_value = NULL;
}
cookie->psz_domain = cookie_get_domain(value);
if ( !cookie->psz_domain || strlen(cookie->psz_domain) == 0 )
{
free(cookie->psz_domain);
cookie->psz_domain = strdup(host);
cookie->b_host_only = true;
}
else
cookie->b_host_only = false;
cookie->psz_path = cookie_get_attribute_value(value, "path" );
if ( !cookie->psz_path || strlen(cookie->psz_path) == 0 )
{
free(cookie->psz_path);
cookie->psz_path = cookie_default_path(path);
}
cookie->b_secure = cookie_has_attribute(value, "secure" );
FREENULL( content );
if ( !cookie->psz_domain || !cookie->psz_path || !cookie->psz_name )
{
cookie_destroy( cookie );
return NULL;
}
return cookie;
}
开发者ID:0xheart0,项目名称:vlc,代码行数:55,代码来源:httpcookies.c
示例20: probe_luascript
/*****************************************************************************
* Called through lua_scripts_batch_execute to call 'probe' on
* the script pointed by psz_filename.
*****************************************************************************/
static int probe_luascript( vlc_object_t *p_this, const char * psz_filename,
lua_State * L, void * user_data )
{
VLC_UNUSED(user_data);
demux_t * p_demux = (demux_t *)p_this;
p_demux->p_sys->psz_filename = strdup(psz_filename);
/* In lua, setting a variable's value to nil is equivalent to deleting it */
lua_pushnil( L );
lua_pushnil( L );
lua_setglobal( L, "probe" );
lua_setglobal( L, "parse" );
/* Load and run the script(s) */
if( luaL_dofile( L, psz_filename ) )
{
msg_Warn( p_demux, "Error loading script %s: %s", psz_filename,
lua_tostring( L, lua_gettop( L ) ) );
goto error;
}
lua_getglobal( L, "probe" );
if( !lua_isfunction( L, -1 ) )
{
msg_Warn( p_demux, "Error while runing script %s, "
"function probe() not found", psz_filename );
goto error;
}
if( lua_pcall( L, 0, 1, 0 ) )
{
msg_Warn( p_demux, "Error while runing script %s, "
"function probe(): %s", psz_filename,
lua_tostring( L, lua_gettop( L ) ) );
goto error;
}
if( lua_gettop( L ) )
{
if( lua_toboolean( L, 1 ) )
{
msg_Dbg( p_demux, "Lua playlist script %s's "
"probe() function was successful", psz_filename );
lua_pop( L, 1 );
return VLC_SUCCESS;
}
}
error:
lua_pop( L, 1 );
FREENULL( p_demux->p_sys->psz_filename );
return VLC_EGENERIC;
}
开发者ID:shanewfx,项目名称:vlc-arib,代码行数:59,代码来源:demux.c
注:本文中的FREENULL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论