static void uca_ring_buffer_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { UcaRingBufferPrivate *priv; g_return_if_fail (UCA_IS_RING_BUFFER (object)); priv = UCA_RING_BUFFER_GET_PRIVATE (object); switch (property_id) { case PROP_BLOCK_SIZE: priv->block_size = (gsize) g_value_get_uint64 (value); realloc_mem (priv); break; case PROP_NUM_BLOCKS: priv->n_blocks_total = g_value_get_uint (value); realloc_mem (priv); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static int add_page( struct cache *c ) { int new_page_index; char **new_pages; char *new_page; new_pages = realloc_mem( c->pages, sizeof( char * ) * ( c->page_count + 1 ) ); if( !new_pages ) { return -1; } new_page = alloc_mem( c->page_size ); if( !new_page ) { return -1; } new_page_index = c->page_count; c->page_count++; c->pages = new_pages; c->pages[new_page_index] = new_page; init_page( c, new_page_index ); return new_page_index; }
struct stumpless_element * stumpless_add_param( struct stumpless_element *element, struct stumpless_param *param ) { struct stumpless_param **new_params; size_t old_params_size; size_t new_params_size; clear_error( ); if( !element ) { raise_argument_empty( "element is NULL" ); return NULL; } if( !param ) { raise_argument_empty( "param is NULL" ); return NULL; } old_params_size = sizeof( param ) * element->param_count; new_params_size = old_params_size + sizeof( param ); new_params = realloc_mem( element->params, new_params_size ); if( !new_params ) { return NULL; } new_params[element->param_count] = param; element->param_count++; element->params = new_params; return element; }
struct stumpless_entry * stumpless_add_element( struct stumpless_entry *entry, struct stumpless_element *element ) { struct stumpless_element **new_elements; size_t old_elements_size; size_t new_elements_size; clear_error( ); if( !entry ) { raise_argument_empty( "entry is NULL" ); return NULL; } if( !element ) { raise_argument_empty( "element is NULL" ); return NULL; } // todo need to check for duplicates first old_elements_size = sizeof( element ) * entry->element_count; new_elements_size = old_elements_size + sizeof( element ); new_elements = realloc_mem( entry->elements, new_elements_size ); if( !new_elements ) { return NULL; } new_elements[entry->element_count] = element; entry->elements = new_elements; entry->element_count++; return entry; }
int32 conn_resize(MeshConnectivity *conn, uint32 num, uint32 n_incident) { int32 ret = RET_OK; conn->num = num; conn->offsets = realloc_mem(conn->offsets, uint32, num + 1); ERR_CheckGo(ret); conn->n_incident = n_incident; conn->indices = realloc_mem(conn->indices, uint32, n_incident); ERR_CheckGo(ret); end_label: if (ERR_Chk) { errput("conn_resize() failed!"); } return(ret); }
char *str_or ( char *str, char *strPrime ) { int len, lenPrime, i; char *fn = "String OR"; if ( (lenPrime = strcspn( strPrime, str )) == 0 ) return str; len = strlen( str ); str = (char *)realloc_mem( str, len+lenPrime+1, sizeof( char ), fn ); for ( i = 0 ; i < strlen( strPrime ) ; i++ ) str_addch( str, strPrime[i] ); return str; }