本文整理汇总了C++中delete_list函数的典型用法代码示例。如果您正苦于以下问题:C++ delete_list函数的具体用法?C++ delete_list怎么用?C++ delete_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_acpi_fan
/* reads the names of the fan directories, fills fan_t,
* return 0 on success, negative values on errors */
int
init_acpi_fan(global_t *globals){
char *names[MAX_ITEMS];
list_t *lst = NULL;
node_t *node = NULL;
int i = 0;
fan_t *finfo = NULL;
globals->fan_count = 0;
if((lst = dir_list(PROC_ACPI "fan")) == NULL || !lst->top)
return NOT_SUPPORTED;
for(node = lst->top; node; node = node->next){
if((names[globals->fan_count] = strdup(node->name)) == NULL){
delete_list(lst);
return ALLOC_ERR;
}
globals->fan_count++;
}
if(globals->fan_count > MAX_ITEMS) return ITEM_EXCEED;
for (; i < globals->fan_count && i < MAX_ITEMS; i++){
finfo = &fans[i];
snprintf(finfo->name, MAX_NAME, "%s", names[i]);
snprintf(finfo->state_file, MAX_NAME, PROC_ACPI "fan/%s/state", names[i]);
free(names[i]);
}
delete_list(lst);
read_acpi_fans(globals);
return SUCCESS;
}
示例2: init_acpi_thermal
/* reads the name of the thermal-zone directory and fills the adapter_t
* structure with the name and the state-file. Return 0 on success, negative values on errors */
int
init_acpi_thermal(global_t *globals){
char *names[MAX_ITEMS];
list_t *lst = NULL;
node_t *node = NULL;
thermal_t *tinfo = NULL;
int i = 0;
globals->thermal_count = 0;
if((lst = dir_list(PROC_ACPI "thermal_zone")) == NULL)
return NOT_SUPPORTED;
for(node = lst->top; node; node = node->next){
if((names[globals->thermal_count] = strdup(node->name)) == NULL){
delete_list(lst);
return ALLOC_ERR;
}
globals->thermal_count++;
}
if(globals->thermal_count > MAX_ITEMS) return ITEM_EXCEED;
for (; i < globals->thermal_count && i < MAX_ITEMS; i++){
tinfo = &thermals[i];
snprintf(tinfo->name, MAX_NAME, "%s", names[i]);
snprintf(tinfo->state_file, MAX_NAME, PROC_ACPI "thermal_zone/%s/state", names[i]);
snprintf(tinfo->temp_file, MAX_NAME, PROC_ACPI "thermal_zone/%s/temperature", names[i]);
snprintf(tinfo->cooling_file, MAX_NAME, PROC_ACPI "thermal_zone/%s/cooling_mode", names[i]);
snprintf(tinfo->freq_file, MAX_NAME, PROC_ACPI "thermal_zone/%s/polling_frequency", names[i]);
snprintf(tinfo->trips_file, MAX_NAME, PROC_ACPI "thermal_zone/%s/trip_points", names[i]);
free(names[i]);
}
delete_list(lst);
read_acpi_thermalzones(globals);
return SUCCESS;
}
示例3: init_acpi_acadapt
/* reads the name of the ac-adapter directory and fills the adapter_t
* structure with the name and the state-file. Return 0 on success, negative values on errors */
int
init_acpi_acadapt(global_t *globals){
list_t *lst = NULL;
adapter_t *ac = &globals->adapt;
globals->sysstyle = 0;
if((lst = dir_list(PROC_ACPI "ac_adapter")) == NULL || !lst->top)
{
if((lst = dir_list(SYS_POWER "/AC")) == NULL || !lst->top)
return NOT_SUPPORTED;
else
globals->sysstyle = 1;
}
if((!lst->top->name || ((ac->name = strdup(lst->top->name)) == NULL))){
delete_list(lst);
return ALLOC_ERR;
}
if(globals->sysstyle)
snprintf(ac->state_file, MAX_NAME, SYS_POWER "/AC/online");
else
snprintf(ac->state_file, MAX_NAME, PROC_ACPI "ac_adapter/%s/state", ac->name);
delete_list(lst);
read_acpi_acstate(globals);
return SUCCESS;
}
示例4: main
int main() {
node* head = new node(0);
node* app = head;
for(int i = 0; i < 10; ++i) {
append(app, i);
app = app->next;
}
remove_duplicates(head);
node* curr = head;
while(curr) {
std::cout << curr->data << " ";
curr = curr->next;
}
std::cout << std::endl;
delete_list(head);
head = new node(0);
app = head;
for(int i = 0; i < 10; ++i) {
append(app, i);
app = app->next;
}
remove_dups_hash(head);
curr = head;
while(curr) {
std::cout << curr->data << " ";
curr = curr->next;
}
std::cout << std::endl;
delete_list(head);
}
示例5: ConfigShutdown
m64p_error ConfigShutdown(void)
{
/* first, save the file if necessary */
if (l_SaveConfigOnExit)
ConfigSaveFile();
/* reset the initialized flag */
if (!l_ConfigInit)
return M64ERR_NOT_INIT;
l_ConfigInit = 0;
/* free any malloc'd local variables */
if (l_DataDirOverride != NULL)
{
free(l_DataDirOverride);
l_DataDirOverride = NULL;
}
if (l_ConfigDirOverride != NULL)
{
free(l_ConfigDirOverride);
l_ConfigDirOverride = NULL;
}
/* free all of the memory in the 2 lists */
delete_list(&l_ConfigListActive);
delete_list(&l_ConfigListSaved);
return M64ERR_SUCCESS;
}
示例6: test_exit
void test_exit(char *buffer, t_list *list)
{
char **tab;
tab = NULL;
if (buffer == NULL || buffer == 0)
{
free(buffer);
write(1, "exit\n", 5);
delete_list(&list);
exit(0);
}
tab = my_str_to_tab(buffer, ' ', 9);
if (tab[0] != NULL)
if (my_strcmp_exit(tab[0], "exit"))
{
if (!tab[1] || (tab[1] && !tab[2]))
{
delete_list(&list);
free(buffer);
write(1, "exit\n", 5);
free(tab);
exit(my_getnbr(tab[1]));
}
write(2, "exit: Expression Syntax.\n", 25);
}
free(tab);
}
示例7: request_clear
void request_clear(request_t* request)
{
list_t* n;
if (request->path)
free(request->path);
n = request->pathnodes;
while (n) {
free(n->data);
n = n->next;
}
delete_list(request->pathnodes);
n = request->args;
while (n) {
delete_pair((pair_t*)n->data);
n = n->next;
}
delete_list(request->args);
n = request->headers;
while (n) {
delete_pair((pair_t*)n->data);
n = n->next;
}
delete_list(request->headers);
if (request->body)
free(request->body);
memset(request, 0, sizeof(request_t));
}
示例8: lookup_flow_entry
flow_entry *
lookup_flow_entry( const uint8_t table_id, const match *match ) {
assert( valid_table_id( table_id ) || table_id == FLOW_TABLE_ALL );
if ( !lock_pipeline() ) {
return NULL;
}
// FIXME: allocating/freeing linked list elements may cost.
list_element *list = NULL;
if ( table_id != FLOW_TABLE_ALL ) {
list = lookup_flow_entries_with_table_id( table_id, match, 0, false, true );
}
else {
list = lookup_flow_entries_from_all_tables( match, 0, false, true );
}
if ( !unlock_pipeline() ) {
delete_list( list );
return NULL;
}
flow_entry *entry = NULL;
if ( list != NULL ) {
entry = list->data;
delete_list( list );
}
return entry;
}
示例9: stop_switch
static void
stop_switch() {
if ( switch_info.secure_channel_fd >= 0 ) {
close( switch_info.secure_channel_fd );
switch_info.secure_channel_fd = -1;
}
uint8_t state = MESSENGER_OPENFLOW_DISCONNECTED;
if ( switch_info.state == SWITCH_STATE_CONNECTION_FAILED ) {
state = MESSENGER_OPENFLOW_FAILD_TO_CONNECT;
}
service_send_state( &switch_info, &switch_info.datapath_id, state );
flush_messenger();
// free service name list
iterate_list( switch_info.vendor_service_name_list, xfree_data, NULL );
delete_list( switch_info.vendor_service_name_list );
switch_info.vendor_service_name_list = NULL;
iterate_list( switch_info.packetin_service_name_list, xfree_data, NULL );
delete_list( switch_info.packetin_service_name_list );
switch_info.packetin_service_name_list = NULL;
iterate_list( switch_info.portstatus_service_name_list, xfree_data, NULL );
delete_list( switch_info.portstatus_service_name_list );
switch_info.portstatus_service_name_list = NULL;
iterate_list( switch_info.state_service_name_list, xfree_data, NULL );
delete_list( switch_info.state_service_name_list );
switch_info.state_service_name_list = NULL;
stop_trema();
}
示例10: delete_list
const t_io *destroy_server_io(const t_io *io)
{
if (io)
{
delete_list(io->in, NULL);
delete_list(io->out, NULL);
}
return (NULL);
}
示例11: game_over
void game_over(Game *g) {
while(!key[KEY_ENTER])
if(key[KEY_ESC]) {
g->end = 1;
return;
}
delete_list(g->asteroids);
delete_list(g->shot);
delete_list(g->particles);
init_game(g);
}
示例12: cleanup
void cleanup(node_data **data){
if ((*data)->neighbours)
delete_list(&(((*data)->neighbours)->head));
if ((*data)->neighbours_cost)
delete_list(&(((*data)->neighbours_cost)->head));
if ((*data)->messages)
delete_list(&(((*data)->messages)->head));
free(*data);
*data = NULL;
}
示例13: getAngles
PyObject* getAngles(PyObject *self, PyObject *args) {
/*
** Inputs:
** interger of search radius (in pixels)
** Modifies:
** nothing
** Outputs:
** 1D numpy array containing correlation values of angle (x-axis)
*/
Py_Initialize();
int radius;
if (!PyArg_ParseTuple(args, "i", &radius))
return NULL;
struct item *head = NULL;
head = getAnglesList(radius, head);
int numangles = list_length(head);
npy_intp outdims[1] = {numangles};
import_array(); // this is required to use PyArray_New() and PyArray_SimpleNew()
PyArrayObject *output;
output = (PyArrayObject *) PyArray_SimpleNew(1, outdims, NPY_DOUBLE);
struct item *current;
int i=0;
for(current=head; current!=NULL; current=current->next) {
*(double *) PyArray_GETPTR1(output, i) = current->angle;
i++;
}
delete_list(head);
return PyArray_Return(output);
}
示例14: delete_flow_entries_by_group_id
OFDPE
delete_flow_entries_by_group_id( const uint32_t group_id ) {
assert( valid_group_id( group_id ) );
if ( !lock_pipeline() ) {
return ERROR_LOCK;
}
list_element *delete_us = NULL;
create_list( &delete_us );
for ( uint8_t table_id = 0; table_id <= FLOW_TABLE_ID_MAX; table_id++ ) {
flow_table *table = get_flow_table( table_id );
assert( table != NULL );
for ( list_element *e = table->entries; e != NULL; e = e->next ) {
assert( e->data != NULL );
flow_entry *entry = e->data;
if ( instructions_have_output_group( entry->instructions, group_id ) ) {
append_to_tail( &delete_us, e->data );
}
}
}
delete_flow_entries_in_list( delete_us, 0, 0, OFPP_ANY, OFPG_ANY, OFPRR_GROUP_DELETE );
if ( delete_us != NULL ) {
delete_list( delete_us );
}
if ( !unlock_pipeline() ) {
return ERROR_UNLOCK;
}
return OFDPE_SUCCESS;
}
示例15: finalize_flow_table
OFDPE
finalize_flow_table( const uint8_t table_id ) {
if ( !valid_table_id( table_id ) ) {
error( "Invalid flow table id ( %#x ).", table_id );
return OFDPE_FAILED;
}
flow_table *table = get_flow_table( table_id );
if ( table == NULL ) {
return OFDPE_FAILED;
}
delete_timer_event_safe( age_flow_entries, &table->features.table_id );
for ( list_element *e = table->entries; e != NULL; e = e->next ) {
flow_entry *entry = e->data;
if ( entry != NULL ) {
free_flow_entry( entry );
}
}
delete_list( table->entries );
memset( table, 0, sizeof( flow_table ) );
table->initialized = false;
return OFDPE_SUCCESS;
}