Frama-C-discuss mailing list archives

This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] slicing problem


  • Subject: [Frama-c-discuss] slicing problem
  • From: ehoa20 at bath.ac.uk (ehoa20 at bath.ac.uk)
  • Date: Thu, 15 Sep 2011 15:20:38 +0100

Hi all
i have the following c code and i want to make slice just inside  
procedure calculate for array a[k] not for the whole program . pls can  
you tell me how can i do that.

  #include<stdio.h>

struct _list1
{
int data;
struct _list1 *next1;
};
typedef struct _list1 list1;

struct _reco {
int data;
list1 *right ;
struct _reco *next;
};
typedef struct _reco reco;

reco *p,*q, *p1,*p2;
long a[1000],a1[1000];

reco * makelist(int x)
{
  int i;
   p=NULL;
   p1=malloc(sizeof(reco));
   p1->data=NULL;
   p=p1;
   for(i=1;i<x;i++)
      {
       p2=malloc(sizeof(reco));
       p2->data=i;
       p1->next=p2;
       p2->next=NULL;
       p2->right=NULL;
       p1=p2;
     }
return p;
}

list1 * makelist2(int x)
{
   list1 *pw,*pw1,*pw2;
  int i;
   pw=NULL;
   pw1=malloc(sizeof(list1));
   pw1->data=NULL;
   pw=pw1;
   for(i=1;i<x;i++)
      {
       pw2=malloc(sizeof(list1));
       pw2->data=i;
       pw1->next1=pw2;
       pw2->next1=NULL;
       pw1=pw2;
     }
return pw;
}



calculate(reco *mp)
{
list1 *p11,*p21,*p31,*v;
   int i,i1,temp;
    long sum=0;
    long sum1=0;
   p11=mp->right->next1;
   int k=0;
   while (p11->next1!=NULL)
     {
       // printf(" the data %d\n",p11->data);
        if(p11->data <500)
         {
           for (i=1;i<=p11->data;i++)
            {
             sum=sum+sin(i);
             }
           //  printf(" the factorial %d\n",fact);
             a[k]=sum;
             k=k+1;
            }

       p11=p11->next1;
     }

  p21=mp->right->next1;
   int k2=0;
   while (p21->next1!=NULL)
     {
       // printf(" the data %d\n",p11->data);
        if(p21->data <500)
         {
           for (i1=1;i1<=p21->data;i1++)
            {
             sum1=sum1+cos(i1);
             }
           //  printf(" the factorial %d\n",fact);
             a1[k2]=sum1;
             k2=k2+1;
            }

       p21=p21->next1;
     }

}


int main()
{
   int x;
   x=100;
list1 *w;
   p=makelist(x);
   q=p;

   while(q!= NULL)
    {
      x=500;

      w=makelist2(x);
     q->right=w;
      q=q->next;
    }
int k1=0;
   while (p!= NULL) // main loop
    {
     calculate(p);
     p=p->next;
    }
}

many thanks
esraa