[x264-devel] [PATCH] improve malloc checks to allow graceful exit on malloc failures

Steven Walters kemuri9 at gmail.com
Sun Jul 26 07:58:57 CEST 2009


On Sat, Jul 25, 2009 at 9:13 PM, Loren Merritt<lorenm at u.washington.edu> wrote:
> Who said anything about mallocing on pthread_exit? The value returned from a
> thread, whether via return or pthread_exit, is a void*. But that doesn't
> mean it has to be a pointer, you can just cast it to int.
> IMO one cast is an acceptable cost for moving a variable from x264_t to the
> stack.
>
> --Loren Merritt
> _______________________________________________
> x264-devel mailing list
> x264-devel at videolan.org
> http://mailman.videolan.org/listinfo/x264-devel
>

Ok, honestly i had a somewhat difficult time trying to come up with
something to not create a malloc, and not add a variable to x264_t.
then came the following idea a bit ago:

static int x264_slices_write( ... )
{
+static int ret[X264_THREAD_MAX];
...
+x264_pthread_exit( &ret[h->i_thread_num] )
+return ret[h->i_thread_num];
}

int x264_encoder_encode( ... )
{
...
 h = thread_current;
+h->i_thread_num = i%t;
//fprintf( ... );
...
}

static int x264_encoder_frame_end( ... )
{
+int UNUSED *ret = NULL;
...
-x264_pthread_join( h->thread_handle, NULL );
+x264_pthread_join( h->thread_handle, (void **)&ret );
+if( ret && *ret )
+  return *ret;
...
}

would something like this be what you're looking for? (acceptable?)


More information about the x264-devel mailing list