Exemple #1
0
int init(int argc, char **argv, 
          global_options *options, list_node *test_list)
{    
    int i, ret = 0;
#ifdef WIN32
    DWORD attrs;    
#else
    struct stat buf;
#endif

    srand((unsigned int) time(NULL));

    /* Check the specified root directory */
#ifdef WIN32
    attrs = GetFileAttributes(options->root_dir);

    /* root directory must be found */
    if ((attrs == INVALID_FILE_ATTRIBUTES) || 
        !(attrs & FILE_ATTRIBUTE_DIRECTORY))
        return FALSE;
#else
    ret = stat(options->root_dir, &buf);
    if (ret != 0 || !(S_ISDIR(buf.st_mode)))
        return FALSE;
#endif

    /* option default */
    options->report_flags = REPORT_CONSOLE;

    /* get options */
    i = 2;
    while (i < argc)
    {
        if (argv[i][0] == '-')
            ret = setoption(argc, argv, options, &i);            
        else 
            add_list_node(test_list, argv[i], strlen(argv[i])+1);

        if (ret != 0)
            return FALSE;

        i++;
    }

    return TRUE;
}
void perform_hint_action(int hint_id, int resource_values[], int num_resources)
{
    if (qcopt_handle) {
        if (perf_lock_acq) {
            /* Acquire an indefinite lock for the requested resources. */
            int lock_handle = perf_lock_acq(0, 0, resource_values,
                    num_resources);

            if (lock_handle == -1) {
                ALOGE("Failed to acquire lock.");
            } else {
                /* Add this handle to our internal hint-list. */
                struct hint_data *new_hint =
                    (struct hint_data *)malloc(sizeof(struct hint_data));

                if (new_hint) {
                    if (!active_hint_list_head.compare) {
                        active_hint_list_head.compare =
                            (int (*)(void *, void *))hint_compare;
                        active_hint_list_head.dump = (void (*)(void *))hint_dump;
                    }

                    new_hint->hint_id = hint_id;
                    new_hint->perflock_handle = lock_handle;

                    if (add_list_node(&active_hint_list_head, new_hint) == NULL) {
                        free(new_hint);
                        /* Can't keep track of this lock. Release it. */
                        if (perf_lock_rel)
                            perf_lock_rel(lock_handle);

                        ALOGE("Failed to process hint.");
                    }
                } else {
                    /* Can't keep track of this lock. Release it. */
                    if (perf_lock_rel)
                        perf_lock_rel(lock_handle);

                    ALOGE("Failed to process hint.");
                }
            }
        }
    }
}
Exemple #3
0
void burst()
{
     int x, y;
     int r, c;
     int centerr, centerc;
     int centerx, centery;
     int line_size, radius;
     char cut;
     list_node_t *head, *n, *temp;


     clear_invert_map();

     centerr = map.num_row/2;
     centerc = map.num_col/2;
     section_center(&centerx, &centery, centerr, centerc);

     radius = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height)/4.0;
     radius = (radius == 0 ? 1 : radius );

     line_size = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height)/4.0;
     line_size = (line_size == 0 ? 1 : line_size);

     head = NULL;

     for( r = 0; r < map.num_row; r++ )
     {
          for( c = 0; c < map.num_col; c++ )
          {
               cut = 0;

               /*
               * if top left, top center, top right
               * or center
               * or bottom left, bottom center, bottom right
               */
               if( (r == 0 && (c == 0 || c == centerc || c == map.num_col-1))
               || (r == centerr && c == centerc)
               || (r == map.num_row-1
               && (c == 0 || c == centerc || c == map.num_col-1)))
                    cut = 1;
               else if( rand()%3 == 0 )
                    cut = 1;
               else
                    cut = 0;

               if( cut == 1 )
               {
                    section_center(&x, &y, r, c);
                    circlefill(map.map, x, y, radius, 255);
printf("cutting(r,c): %d, %d\n", r, c);
                    head = add_list_node(head, x, y);
printf("after adding list node\n");
               }
          }
     }


     for( n = head; n != NULL; n = temp )
     {
          cut_line(n->x, n->y, centerx, centery, line_size);
          temp = n->next;
          free(n);
printf("freeing node...\n");
     }

     /* TODO: do i need this: cut outline around map... */

return;
}