From 1b9e19bba9f837a56cc70072c21342028a3b96bb Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Tue, 1 Feb 2005 09:37:33 +0000 Subject: [PATCH 1/1] 64 bit fix and deque int holding git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@651 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/framework/mlt_deque.c | 97 +++++++++++++++++++++++++++++++++++++++----- src/framework/mlt_deque.h | 8 ++++ src/framework/mlt_frame.c | 16 +++++++ src/framework/mlt_frame.h | 2 + 4 files changed, 112 insertions(+), 11 deletions(-) diff --git a/src/framework/mlt_deque.c b/src/framework/mlt_deque.c index 4d5a2bd..d5ec8d8 100644 --- a/src/framework/mlt_deque.c +++ b/src/framework/mlt_deque.c @@ -25,12 +25,19 @@ #include #include +typedef union +{ + void *addr; + int value; +} +deque_entry; + /** Private structure. */ struct mlt_deque_s { - void **list; + deque_entry *list; int size; int count; }; @@ -65,7 +72,7 @@ static int mlt_deque_allocate( mlt_deque this ) { if ( this->count == this->size ) { - this->list = realloc( this->list, sizeof( void * ) * ( this->size + 20 ) ); + this->list = realloc( this->list, sizeof( deque_entry ) * ( this->size + 20 ) ); this->size += 20; } return this->list == NULL; @@ -79,7 +86,7 @@ int mlt_deque_push_back( mlt_deque this, void *item ) int error = mlt_deque_allocate( this ); if ( error == 0 ) - this->list[ this->count ++ ] = item; + this->list[ this->count ++ ].addr = item; return error; } @@ -89,7 +96,7 @@ int mlt_deque_push_back( mlt_deque this, void *item ) void *mlt_deque_pop_back( mlt_deque this ) { - return this->count > 0 ? this->list[ -- this->count ] : NULL; + return this->count > 0 ? this->list[ -- this->count ].addr : NULL; } /** Queue an item at the start. @@ -101,8 +108,8 @@ int mlt_deque_push_front( mlt_deque this, void *item ) if ( error == 0 ) { - memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( void * ) ); - this->list[ 0 ] = item; + memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) ); + this->list[ 0 ].addr = item; } return error; @@ -117,8 +124,8 @@ void *mlt_deque_pop_front( mlt_deque this ) if ( this->count > 0 ) { - item = this->list[ 0 ]; - memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( void * ) ); + item = this->list[ 0 ].addr; + memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) ); } return item; @@ -129,7 +136,7 @@ void *mlt_deque_pop_front( mlt_deque this ) void *mlt_deque_peek_back( mlt_deque this ) { - return this->count > 0 ? this->list[ this->count - 1 ] : NULL; + return this->count > 0 ? this->list[ this->count - 1 ].addr : NULL; } /** Inquire on item at front of deque but don't remove. @@ -137,7 +144,76 @@ void *mlt_deque_peek_back( mlt_deque this ) void *mlt_deque_peek_front( mlt_deque this ) { - return this->count > 0 ? this->list[ 0 ] : NULL; + return this->count > 0 ? this->list[ 0 ].addr : NULL; +} + +/** Push an item to the end. +*/ + +int mlt_deque_push_back_int( mlt_deque this, int item ) +{ + int error = mlt_deque_allocate( this ); + + if ( error == 0 ) + this->list[ this->count ++ ].value = item; + + return error; +} + +/** Pop an item. +*/ + +int mlt_deque_pop_back_int( mlt_deque this ) +{ + return this->count > 0 ? this->list[ -- this->count ].value : 0; +} + +/** Queue an item at the start. +*/ + +int mlt_deque_push_front_int( mlt_deque this, int item ) +{ + int error = mlt_deque_allocate( this ); + + if ( error == 0 ) + { + memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) ); + this->list[ 0 ].value = item; + } + + return error; +} + +/** Remove an item from the start. +*/ + +int mlt_deque_pop_front_int( mlt_deque this ) +{ + int item = 0; + + if ( this->count > 0 ) + { + item = this->list[ 0 ].value; + memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) ); + } + + return item; +} + +/** Inquire on item at back of deque but don't remove. +*/ + +int mlt_deque_peek_back_int( mlt_deque this ) +{ + return this->count > 0 ? this->list[ this->count - 1 ].value : 0; +} + +/** Inquire on item at front of deque but don't remove. +*/ + +int mlt_deque_peek_front_int( mlt_deque this ) +{ + return this->count > 0 ? this->list[ 0 ].value : 0; } /** Close the queue. @@ -149,4 +225,3 @@ void mlt_deque_close( mlt_deque this ) free( this ); } - diff --git a/src/framework/mlt_deque.h b/src/framework/mlt_deque.h index fd16815..f70a390 100644 --- a/src/framework/mlt_deque.h +++ b/src/framework/mlt_deque.h @@ -31,6 +31,14 @@ extern int mlt_deque_push_front( mlt_deque self, void *item ); extern void *mlt_deque_pop_front( mlt_deque self ); extern void *mlt_deque_peek_back( mlt_deque self ); extern void *mlt_deque_peek_front( mlt_deque self ); + +extern int mlt_deque_push_back_int( mlt_deque self, int item ); +extern int mlt_deque_pop_back_int( mlt_deque self ); +extern int mlt_deque_push_front_int( mlt_deque self, int item ); +extern int mlt_deque_pop_front_int( mlt_deque self ); +extern int mlt_deque_peek_back_int( mlt_deque self ); +extern int mlt_deque_peek_front_int( mlt_deque self ); + extern void mlt_deque_close( mlt_deque self ); #endif diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index 660f3c1..1637dad 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -181,6 +181,22 @@ void *mlt_frame_pop_service( mlt_frame this ) return mlt_deque_pop_back( this->stack_image ); } +/** Push a service. +*/ + +int mlt_frame_push_service_int( mlt_frame this, int that ) +{ + return mlt_deque_push_back_int( this->stack_image, that ); +} + +/** Pop a service. +*/ + +int mlt_frame_pop_service_int( mlt_frame this ) +{ + return mlt_deque_pop_back_int( this->stack_image ); +} + /** Push an audio item on the stack. */ diff --git a/src/framework/mlt_frame.h b/src/framework/mlt_frame.h index 899b0d2..77ca012 100644 --- a/src/framework/mlt_frame.h +++ b/src/framework/mlt_frame.h @@ -63,6 +63,8 @@ extern int mlt_frame_push_frame( mlt_frame self, mlt_frame that ); extern mlt_frame mlt_frame_pop_frame( mlt_frame self ); extern int mlt_frame_push_service( mlt_frame self, void *that ); extern void *mlt_frame_pop_service( mlt_frame self ); +extern int mlt_frame_push_service_int( mlt_frame self, int that ); +extern int mlt_frame_pop_service_int( mlt_frame self ); extern int mlt_frame_push_audio( mlt_frame self, void *that ); extern void *mlt_frame_pop_audio( mlt_frame self ); extern mlt_deque mlt_frame_service_stack( mlt_frame self ); -- 1.7.4.4