Esempio n. 1
0
bool quick_entire(char* regex, char* str) {
   assert(regex);
   assert(str);
   pattern_t* pattern = shre_compile(regex);
   if (!pattern)
      return false;
   range_t* groups =
             core_match(pattern->core, str, NULL, NULL,
                                       NULL, 0, &trash, str);
   if (!groups)
      return false;
   if (*(range_group(groups, 0)->end) == '\0') {
      range_free(groups);
      return true;
   }
   range_free(groups);
   return false;
}
Esempio n. 2
0
void geo_unload(geo_t *g) {
    if (g->geo_mode == GEO_RANGE) {
        range_free(g->u.range);
    } else if (g->geo_mode == GEO_CIDR) {
        radix_tree_free(g->u.tree);
    } else {
        /* should NOT get here */
        assert(0);
    }
    free(g);
}
Esempio n. 3
0
void bts_free(bts_t* obj) {
   if (obj) {
      while (obj->top) {
         if (obj->top->state.recursive) {
            bts_free(obj->top->state.inner);
            if (obj->top->state.nest)
               range_free(obj->top->state.nest);
         }
         bts_pop(obj);
      }
      free(obj);
   }
}
Esempio n. 4
0
bool quick_search(char* regex, char* str) {
   assert(regex);
   assert(str);
   pattern_t* pattern = shre_compile(regex);
   if (!pattern)
      return false;
   char* start = str;
   while (*str != '\0') {
      range_t* groups =
           core_match(pattern->core, ++str, NULL, NULL, 
                                  NULL, 0, &trash, start);
      if (groups) {
         range_free(groups);
         return true;
      }
   }
   return false;
}
void correct_attributes_after_delete(MyAtkText* text, gint position, gint length)
{
    GList *attributes = text->attributes;
    GList *tmp = attributes;
    //before deleting range
    for(tmp = attributes; tmp != NULL; tmp = tmp->next)
    {
        Range* range  = (Range*)tmp->data;
        if(range->end <= position) continue;
        if(range->start < position)
        {
             if(range->end > position + length) range->end -= length;
             else range->end = position;
             tmp = tmp->next;
        }
        break;
    }
    //at deleting range
    while(tmp != NULL)
    {
        Range* range = (Range*)tmp->data;
        if(range->start >= position + length) break;
        if(range->end <= position + length)
        {
            GList *tmp1 = tmp->next;
            range_free(range);
            attributes = g_list_remove_link(attributes, tmp);
            tmp = tmp1;
            continue;
        }
        //range->end > position + length
        //range->start < position + length
        range->start = position + length;//will be restored in next loop
        break;
    }
    //after deleting range
    for(;tmp != NULL; tmp = tmp->next)
    {
        Range* range = (Range*)tmp->data;
        range->end -= length;
        range->start -= length;
    }
    text->attributes = attributes;
}
Esempio n. 6
0
void match_free(match_t* match) {
   if (match) {;
      range_free(match->groups);
      free(match);
   }
}
Esempio n. 7
0
EXT void maxlike_precalculate
  (maxlike_wk* max)
{


  #define H_Amp           10.0
  #define H_Step          65535
  #define H_Rez           (H_Amp/H_Step)


  int i = 0, j = 0, theta = 0, x = 0, y = 0, q = 0;
  int M = max-> state-> n + 1;
  int T = max-> data-> gd-> x-> n_val;
  int X = max-> data-> gd-> y-> n_val;
  int Q = H_Step;

  int sign = 1;

  Real accum, thres, a, b;
  Real rez = max-> data-> gd-> y-> resolution;

  range* r = range_single(H_Step, H_Amp);
  hermite_workspace* h  = hermite_alloc(max-> state-> n, r);
  hermite_calculate(h);

  Real** c_lup = (Real**) malloc( sizeof(Real*) * M );
  Real** s_lup = (Real**) malloc( sizeof(Real*) * M );

  i = 0;
  while(M-i) {

    c_lup[i] = (Real*) malloc( sizeof(Real) * T );
    s_lup[i] = (Real*) malloc( sizeof(Real) * T );

    theta = 0;
    while(T-theta) {
      c_lup[i][theta] = cos( i * (max-> data-> gd-> x-> val[theta]) );
      s_lup[i][theta] = sin( i * (max-> data-> gd-> x-> val[theta]) );
      theta++;
    }  

    i++;
  }

  i = 0;
  while(M - i) {

    j = 0;
    while(i + 1 - j) {

      accum = 0.0;
      thres = rez/2;
      q = 0;
      x = (max-> data-> gd-> y-> n_val)/2;

      while(X - x && Q - q) { 

        accum += h-> harmonics[i][q] * h-> harmonics[j][q];

        if ( r-> val[q] >= thres) {

          thres += rez;
          accum *= r-> resolution;

          theta = 0;
          while(T-theta) {

            max-> proj_re[theta][x][i][j] = c_lup[i-j][theta] * accum;
            max-> proj_im[theta][x][i][j] = s_lup[i-j][theta] * accum;
            theta++;

          }

          x++;
          accum = 0.0;
        }

        q++;
      }  

      j++;
    }

    i++;
  }

  theta = 0;
  while(T-theta) {

    x = (max-> data-> gd-> y-> n_val)/2;
    y = x;

    while(X - x ) { 

      i = 0;
      while(M - i) {

        j = 0;
        while(i + 1 - j) {

            sign = ( (i+j)%2 )? -1 : 1; 

            max-> proj_re[theta][y][i][j] = sign * max-> proj_re[theta][x][i][j];
            max-> proj_im[theta][y][i][j] = sign * max-> proj_im[theta][x][i][j];

            j++;
          }

        i++;
      }  

      x++;
      y--;
    }

    theta++;
  }

  dmatrix* buf = dmatrix_alloc(M-1);

  theta = 0;
  while(T-theta) {

    x = 0;
    while(X - x ) { 

      i = 0;
      while(M - i) {

        j = 0;
        while(i + 1 - j) {

            buf-> re[i][j] = max-> proj_re[theta][x][i][j];
            buf-> im[i][j] = max-> proj_im[theta][x][i][j];

            j++;
          }

        i++;
      }  

      i = 0;
      while(M - i) {

        j = 0;
        while(i + 1 - j) {

            max-> proj_re[theta][x][j][i] = buf-> re[i][j];
            max-> proj_im[theta][x][j][i] =-buf-> im[i][j];

            j++;
          }

        i++;
      }  

      x++;
    }

    theta++;
  }

  dmatrix_free(buf);

  for (i = 0; i < M; i++) {
    free( c_lup[i] ); 
    free( s_lup[i] ); 
  }

  free(c_lup); 
  free(s_lup);

  hermite_free(h); 
  range_free(r);


  #undef H_Amp
  #undef H_Step
  #undef H_Rez

}