win-pvdrivers

view liblfds.6/src/ringbuffer/ringbuffer_new.c @ 1025:aa2e51f67f7c

Fix hibernate under Win8. Change debugprints.
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 19 15:14:53 2013 +1100 (2013-02-19)
parents 6300617040e0
children
line source
1 #include "ringbuffer_internal.h"
7 /****************************************************************************/
8 int ringbuffer_new( struct ringbuffer_state **rs, atom_t number_elements, int (*user_data_init_function)(void **user_data, void *user_state), void *user_state )
9 {
10 int
11 rv = 0;
13 assert( rs != NULL );
14 // TRD : number_elements can be any value in its range
15 // TRD : user_data_init_function can be NULL
16 // TRD : user_state can be NULL
18 *rs = (struct ringbuffer_state *) abstraction_aligned_malloc( sizeof(struct ringbuffer_state), ALIGN_DOUBLE_POINTER );
20 if( *rs != NULL )
21 {
22 freelist_new( &(*rs)->fs, number_elements, user_data_init_function, user_state );
24 if( (*rs)->fs != NULL )
25 {
26 queue_new( &(*rs)->qs, number_elements );
28 if( (*rs)->qs != NULL )
29 rv = 1;
31 if( (*rs)->qs == NULL )
32 {
33 abstraction_aligned_free( *rs );
34 *rs = NULL;
35 }
36 }
38 if( (*rs)->fs == NULL )
39 {
40 abstraction_aligned_free( *rs );
41 *rs = NULL;
42 }
43 }
45 return( rv );
46 }