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