mlt_field mlt_field_init( )
{
// Initialise the field
- mlt_field self = calloc( sizeof( struct mlt_field_s ), 1 );
+ mlt_field self = calloc( 1, sizeof( struct mlt_field_s ) );
// Initialise it
if ( self != NULL )
mlt_field mlt_field_new( mlt_multitrack multitrack, mlt_tractor tractor )
{
// Initialise the field
- mlt_field self = calloc( sizeof( struct mlt_field_s ), 1 );
+ mlt_field self = calloc( 1, sizeof( struct mlt_field_s ) );
// Initialise it
if ( self != NULL )
mlt_filter mlt_filter_new( )
{
mlt_filter self = calloc( 1, sizeof( struct mlt_filter_s ) );
- if ( self != NULL )
- mlt_filter_init( self, NULL );
- return self;
+ if ( self != NULL && mlt_filter_init( self, NULL ) == 0 )
+ {
+ return self;
+ }
+ else
+ {
+ free(self);
+ return NULL;
+ }
}
/** Get the service class interface.
char name[20];
// Make the properties key from unique id
- strcpy( name, "pos." );
- strcat( name, unique_id );
+ snprintf( name, 20, "pos.%s", unique_id );
+ name[20 - 1] = '\0';
return mlt_properties_get_position( MLT_FRAME_PROPERTIES( frame ), name ) - in;
}
char name[20];
// Make the properties key from unique id
- strcpy( name, "pos." );
- strcat( name, unique_id );
+ snprintf( name, 20, "pos.%s", unique_id );
+ name[20 -1] = '\0';
// Save the position on the frame
mlt_properties_set_position( MLT_FRAME_PROPERTIES( frame ), name, position );
mlt_frame mlt_frame_init( mlt_service service )
{
// Allocate a frame
- mlt_frame self = calloc( sizeof( struct mlt_frame_s ), 1 );
+ mlt_frame self = calloc( 1, sizeof( struct mlt_frame_s ) );
if ( self != NULL )
{
unsigned char *bitmap = ( unsigned char* )mlt_pool_alloc( size );
if ( bitmap != NULL )
memset( bitmap, 0, size );
+ else
+ return NULL;
mlt_properties_set_data( properties, "waveform", bitmap, size, ( mlt_destructor )mlt_pool_release, NULL );
// Render vertical lines
mlt_multitrack mlt_multitrack_init( )
{
// Allocate the multitrack object
- mlt_multitrack self = calloc( sizeof( struct mlt_multitrack_s ), 1 );
+ mlt_multitrack self = calloc( 1, sizeof( struct mlt_multitrack_s ) );
if ( self != NULL )
{
mlt_playlist mlt_playlist_init( )
{
- mlt_playlist self = calloc( sizeof( struct mlt_playlist_s ), 1 );
+ mlt_playlist self = calloc( 1, sizeof( struct mlt_playlist_s ) );
if ( self != NULL )
{
mlt_producer producer = &self->parent;
// Construct the producer
- mlt_producer_init( producer, self );
+ if ( mlt_producer_init( producer, self ) != 0 ) goto error1;
// Override the producer get_frame
producer->get_frame = producer_get_frame;
producer->close_object = self;
// Initialise blank
- mlt_producer_init( &self->blank, NULL );
+ if ( mlt_producer_init( &self->blank, NULL ) != 0 ) goto error1;
mlt_properties_set( MLT_PRODUCER_PROPERTIES( &self->blank ), "mlt_service", "blank" );
mlt_properties_set( MLT_PRODUCER_PROPERTIES( &self->blank ), "resource", "blank" );
mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( self ), "length", 0 );
self->size = 10;
- self->list = malloc( self->size * sizeof( playlist_entry * ) );
+ self->list = calloc( self->size, sizeof( playlist_entry * ) );
+ if ( self->list == NULL ) goto error2;
+
}
return self;
+error2:
+ free( self->list );
+error1:
+ free( self );
+ return NULL;
}
/** Construct a playlist with a profile.
}
// Create the entry
- self->list[ self->count ] = calloc( sizeof( playlist_entry ), 1 );
+ self->list[ self->count ] = calloc( 1, sizeof( playlist_entry ) );
if ( self->list[ self->count ] != NULL )
{
self->list[ self->count ]->producer = producer;
mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( self ), "_profile", profile, 0, NULL, NULL );
mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( self ), "aspect_ratio", mlt_profile_sar( profile ) );
}
+ else
+ {
+ free( self );
+ return NULL;
+ }
}
return self;
}
mlt_producer_set_speed( self, 0 );
position = mlt_producer_get_playtime( self ) - 1;
}
- else if ( use_points && !strcmp( eof, "loop" ) && position >= mlt_producer_get_playtime( self ) )
+ else if ( use_points && eof && !strcmp( eof, "loop" ) && position >= mlt_producer_get_playtime( self ) )
{
position = (int)position % (int)mlt_producer_get_playtime( self );
}
self->child = child;
// Allocate the local structure
- self->local = calloc( sizeof( property_list ), 1 );
+ self->local = calloc( 1, sizeof( property_list ) );
// Increment the ref count
( ( property_list * )self->local )->ref_count = 1;
mlt_properties mlt_properties_new( )
{
// Construct a standalone properties object
- mlt_properties self = calloc( sizeof( struct mlt_properties_s ), 1 );
+ mlt_properties self = calloc( 1, sizeof( struct mlt_properties_s ) );
// Initialise self
mlt_properties_init( self, NULL );
// Set the new locale
setlocale( LC_NUMERIC, localename );
}
+ else
+ {
+ // Make sure we have a lock before accessing self->types
+ pthread_mutex_lock( &self->mutex );
+ }
// Convert number to string
if ( self->types & mlt_prop_int )
free( orig_localename );
pthread_mutex_unlock( &self->mutex );
}
+ else
+ {
+ // Make sure we have a lock before accessing self->types
+ pthread_mutex_unlock( &self->mutex );
+ }
// Return the string (may be NULL)
return self->prop_string;
return NULL;
// Construct the repository
- mlt_repository self = calloc( sizeof( struct mlt_repository_s ), 1 );
+ mlt_repository self = calloc( 1, sizeof( struct mlt_repository_s ));
mlt_properties_init( &self->parent, self );
self->consumers = mlt_properties_new();
self->filters = mlt_properties_new();
self->child = child;
// Generate local space
- self->local = calloc( sizeof( mlt_service_base ), 1 );
+ self->local = calloc( 1, sizeof( mlt_service_base ) );
// Associate the methods
self->get_frame = service_get_frame;
mlt_tractor mlt_tractor_init( )
{
- mlt_tractor self = calloc( sizeof( struct mlt_tractor_s ), 1 );
+ mlt_tractor self = calloc( 1, sizeof( struct mlt_tractor_s ) );
if ( self != NULL )
{
mlt_producer producer = &self->parent;
mlt_tractor mlt_tractor_new( )
{
- mlt_tractor self = calloc( sizeof( struct mlt_tractor_s ), 1 );
+ mlt_tractor self = calloc( 1, sizeof( struct mlt_tractor_s ) );
if ( self != NULL )
{
mlt_producer producer = &self->parent;
mlt_filter filter_audioconvert_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) );
if ( mlt_filter_init( this, this ) == 0 )
this->process = filter_process;
return this;
mlt_filter filter_crop_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter filter = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter filter = calloc( 1, sizeof( struct mlt_filter_s ) );
if ( mlt_filter_init( filter, filter ) == 0 )
{
filter->process = filter_process;
mlt_filter filter_imageconvert_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) );
if ( mlt_filter_init( this, this ) == 0 )
{
this->process = filter_process;
mlt_filter filter_panner_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter filter = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter filter = calloc( 1, sizeof( struct mlt_filter_s ) );
if ( filter != NULL && mlt_filter_init( filter, NULL ) == 0 )
{
filter->process = filter_process;
mlt_filter filter_resize_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter filter = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter filter = calloc( 1, sizeof( struct mlt_filter_s ) );
if ( mlt_filter_init( filter, filter ) == 0 )
{
filter->process = filter_process;
mlt_producer producer_ppm_init( mlt_profile profile, mlt_service_type type, const char *id, char *command )
{
- producer_ppm this = calloc( sizeof( struct producer_ppm_s ), 1 );
+ producer_ppm this = calloc( 1, sizeof( struct producer_ppm_s ) );
if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
{
mlt_producer producer = &this->parent;
mlt_transition transition_composite_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_transition self = calloc( sizeof( struct mlt_transition_s ), 1 );
+ mlt_transition self = calloc( 1, sizeof( struct mlt_transition_s ) );
if ( self != NULL && mlt_transition_init( self, NULL ) == 0 )
{
mlt_properties properties = MLT_TRANSITION_PROPERTIES( self );
mlt_transition transition_mix_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_transition this = calloc( sizeof( struct mlt_transition_s ), 1 );
+ mlt_transition this = calloc( 1, sizeof( struct mlt_transition_s ) );
if ( this != NULL && mlt_transition_init( this, NULL ) == 0 )
{
this->process = transition_process;
mlt_producer producer_libdv_init( mlt_profile profile, mlt_service_type type, const char *id, char *filename )
{
- producer_libdv this = calloc( sizeof( struct producer_libdv_s ), 1 );
+ producer_libdv this = calloc( 1, sizeof( struct producer_libdv_s ) );
if ( filename != NULL && this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
{
mlt_producer producer_pango_init( const char *filename )
{
- producer_pango this = calloc( sizeof( struct producer_pango_s ), 1 );
+ producer_pango this = calloc( 1, sizeof( struct producer_pango_s ) );
if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
{
mlt_producer producer = &this->parent;
mlt_producer producer_pixbuf_init( char *filename )
{
- producer_pixbuf self = calloc( sizeof( struct producer_pixbuf_s ), 1 );
+ producer_pixbuf self = calloc( 1, sizeof( struct producer_pixbuf_s ) );
if ( self != NULL && mlt_producer_init( &self->parent, self ) == 0 )
{
mlt_producer producer = &self->parent;
if ( kino_wrapper_open( wrapper, filename ) )
{
- producer_kino this = calloc( sizeof( struct producer_kino_s ), 1 );
+ producer_kino this = calloc( 1, sizeof( struct producer_kino_s ) );
if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
{
mlt_consumer consumer_SDIstream_init(mlt_profile profile, mlt_service_type type, const char *id, char *arg) {
// Create the consumer object
- consumer_SDIstream this = calloc(sizeof(struct consumer_SDIstream_s), 1);
+ consumer_SDIstream this = calloc( 1, sizeof(struct consumer_SDIstream_s) );
// If malloc and consumer init ok
if (this != NULL && mlt_consumer_init(&this->parent, this, profile) == 0) {
mlt_filter filter_volume_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) );
if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
{
mlt_properties properties = MLT_FILTER_PROPERTIES( this );
/* fprintf(stderr, ":::::::::::: CREATE TITLE\n"); */
/* Create a new producer object */
- producer_ktitle this = calloc( sizeof( struct producer_ktitle_s ), 1 );
+ producer_ktitle this = calloc( 1, sizeof( struct producer_ktitle_s ) );
if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
{
mlt_producer producer = &this->parent;
mlt_producer producer_qimage_init( mlt_profile profile, mlt_service_type type, const char *id, char *filename )
{
- producer_qimage self = calloc( sizeof( struct producer_qimage_s ), 1 );
+ producer_qimage self = calloc( 1, sizeof( struct producer_qimage_s ) );
if ( self != NULL && mlt_producer_init( &self->parent, self ) == 0 )
{
mlt_producer producer = &self->parent;
// Allocate necessary internal buffers.\r
unsigned long bufferBytes;\r
bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );\r
- // stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );\r
+ // stream_.userBuffer[mode] = (char *) calloc( 1, bufferBytes );\r
stream_.userBuffer[mode] = (char *) malloc( bufferBytes * sizeof(char) );\r
memset( stream_.userBuffer[mode], 0, bufferBytes * sizeof(char) );\r
if ( stream_.userBuffer[mode] == NULL ) {\r
if ( makeBuffer ) {\r
bufferBytes *= *bufferSize;\r
if ( stream_.deviceBuffer ) free( stream_.deviceBuffer );\r
- stream_.deviceBuffer = (char *) calloc( bufferBytes, 1 );\r
+ stream_.deviceBuffer = (char *) calloc( 1, bufferBytes );\r
if ( stream_.deviceBuffer == NULL ) {\r
errorText_ = "RtApiCore::probeDeviceOpen: error allocating device buffer memory.";\r
goto error;\r
// Allocate necessary internal buffers.\r
unsigned long bufferBytes;\r
bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );\r
- stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );\r
+ stream_.userBuffer[mode] = (char *) calloc( 1, bufferBytes );\r
if ( stream_.userBuffer[mode] == NULL ) {\r
errorText_ = "RtApiJack::probeDeviceOpen: error allocating user buffer memory.";\r
goto error;\r
if ( makeBuffer ) {\r
bufferBytes *= *bufferSize;\r
if ( stream_.deviceBuffer ) free( stream_.deviceBuffer );\r
- stream_.deviceBuffer = (char *) calloc( bufferBytes, 1 );\r
+ stream_.deviceBuffer = (char *) calloc( 1, bufferBytes );\r
if ( stream_.deviceBuffer == NULL ) {\r
errorText_ = "RtApiJack::probeDeviceOpen: error allocating device buffer memory.";\r
goto error;\r
// Allocate necessary internal buffers\r
unsigned long bufferBytes;\r
bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );\r
- stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );\r
+ stream_.userBuffer[mode] = (char *) calloc( 1, bufferBytes );\r
if ( stream_.userBuffer[mode] == NULL ) {\r
errorText_ = "RtApiAsio::probeDeviceOpen: error allocating user buffer memory.";\r
goto error;\r
if ( makeBuffer ) {\r
bufferBytes *= *bufferSize;\r
if ( stream_.deviceBuffer ) free( stream_.deviceBuffer );\r
- stream_.deviceBuffer = (char *) calloc( bufferBytes, 1 );\r
+ stream_.deviceBuffer = (char *) calloc( 1, bufferBytes );\r
if ( stream_.deviceBuffer == NULL ) {\r
errorText_ = "RtApiAsio::probeDeviceOpen: error allocating device buffer memory.";\r
goto error;\r
\r
// Allocate necessary internal buffers\r
long bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );\r
- stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );\r
+ stream_.userBuffer[mode] = (char *) calloc( 1, bufferBytes );\r
if ( stream_.userBuffer[mode] == NULL ) {\r
errorText_ = "RtApiDs::probeDeviceOpen: error allocating user buffer memory.";\r
goto error;\r
if ( makeBuffer ) {\r
bufferBytes *= *bufferSize;\r
if ( stream_.deviceBuffer ) free( stream_.deviceBuffer );\r
- stream_.deviceBuffer = (char *) calloc( bufferBytes, 1 );\r
+ stream_.deviceBuffer = (char *) calloc( 1, bufferBytes );\r
if ( stream_.deviceBuffer == NULL ) {\r
errorText_ = "RtApiDs::probeDeviceOpen: error allocating device buffer memory.";\r
goto error;\r
// Allocate necessary internal buffers.\r
unsigned long bufferBytes;\r
bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );\r
- stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );\r
+ stream_.userBuffer[mode] = (char *) calloc( 1, bufferBytes );\r
if ( stream_.userBuffer[mode] == NULL ) {\r
errorText_ = "RtApiAlsa::probeDeviceOpen: error allocating user buffer memory.";\r
goto error;\r
if ( makeBuffer ) {\r
bufferBytes *= *bufferSize;\r
if ( stream_.deviceBuffer ) free( stream_.deviceBuffer );\r
- stream_.deviceBuffer = (char *) calloc( bufferBytes, 1 );\r
+ stream_.deviceBuffer = (char *) calloc( 1, bufferBytes );\r
if ( stream_.deviceBuffer == NULL ) {\r
errorText_ = "RtApiAlsa::probeDeviceOpen: error allocating device buffer memory.";\r
goto error;\r
// Allocate necessary internal buffers.\r
unsigned long bufferBytes;\r
bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );\r
- stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );\r
+ stream_.userBuffer[mode] = (char *) calloc( 1, bufferBytes );\r
if ( stream_.userBuffer[mode] == NULL ) {\r
errorText_ = "RtApiOss::probeDeviceOpen: error allocating user buffer memory.";\r
goto error;\r
if ( makeBuffer ) {\r
bufferBytes *= *bufferSize;\r
if ( stream_.deviceBuffer ) free( stream_.deviceBuffer );\r
- stream_.deviceBuffer = (char *) calloc( bufferBytes, 1 );\r
+ stream_.deviceBuffer = (char *) calloc( 1, bufferBytes );\r
if ( stream_.deviceBuffer == NULL ) {\r
errorText_ = "RtApiOss::probeDeviceOpen: error allocating device buffer memory.";\r
goto error;\r
mlt_consumer consumer_sdl_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
// Create the consumer object
- consumer_sdl this = calloc( sizeof( struct consumer_sdl_s ), 1 );
+ consumer_sdl this = calloc( 1, sizeof( struct consumer_sdl_s ) );
// If no malloc'd and consumer init ok
if ( this != NULL && mlt_consumer_init( &this->parent, this, profile ) == 0 )
mlt_consumer consumer_sdl_audio_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
// Create the consumer object
- consumer_sdl self = calloc( sizeof( struct consumer_sdl_s ), 1 );
+ consumer_sdl self = calloc( 1, sizeof( struct consumer_sdl_s ) );
// If no malloc'd and consumer init ok
if ( self != NULL && mlt_consumer_init( &self->parent, self, profile ) == 0 )
mlt_consumer consumer_sdl_preview_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- consumer_sdl this = calloc( sizeof( struct consumer_sdl_s ), 1 );
+ consumer_sdl this = calloc( 1, sizeof( struct consumer_sdl_s ) );
if ( this != NULL && mlt_consumer_init( &this->parent, this, profile ) == 0 )
{
// Get the parent consumer object
mlt_consumer consumer_sdl_still_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
// Create the consumer object
- consumer_sdl this = calloc( sizeof( struct consumer_sdl_s ), 1 );
+ consumer_sdl this = calloc( 1, sizeof( struct consumer_sdl_s ) );
// If no malloc'd and consumer init ok
if ( this != NULL && mlt_consumer_init( &this->parent, this, profile ) == 0 )
mlt_consumer consumer_xml_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
// Create the consumer object
- mlt_consumer this = calloc( sizeof( struct mlt_consumer_s ), 1 );
+ mlt_consumer this = calloc( 1, sizeof( struct mlt_consumer_s ) );
// If no malloc'd and consumer init ok
if ( this != NULL && mlt_consumer_init( this, NULL, profile ) == 0 )
{
struct _xmlParserCtxt *xmlcontext = ( struct _xmlParserCtxt* )ctx;
deserialise_context context = ( deserialise_context )( xmlcontext->_private );
- char *value = calloc( len + 1, 1 );
+ char *value = calloc( 1, len + 1 );
enum service_type type;
mlt_service service = context_pop_service( context, &type );
mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
if ( s != NULL )
{
// Append new text to existing content
- char *new = calloc( strlen( s ) + len + 1, 1 );
+ char *new = calloc( 1, strlen( s ) + len + 1 );
strcat( new, s );
strcat( new, value );
mlt_properties_set( properties, context->property, new );