swarm-support
[Top][All Lists]
Advanced

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

alloc


From: Lorenzo
Subject: alloc
Date: Fri, 7 Apr 2000 11:03:25 +0200

I'm a newbye in objective-C. If I write in c:

#include <stdio.h>
#include <malloc.h>

int main();
int main()
{
  int i, j;
  int numCol[5]={8,8,8,9,10};
  char *Ipezzo[5];
  char **labelsHist;

  labelsHist=(char **) malloc(sizeof (char *) * 5);
  for(i=0;i<5;i++)
    {
      Ipezzo[i]=(char *) malloc(sizeof (char) * 2);
      labelsHist[i]=(char *) malloc(sizeof (char) * numCol[i]);
    }
 for(i=0;i<5;i++)
    {
      Ipezzo[i]="x=";
      for (j=0;j<2;j++)
           labelsHist[i][j]=Ipezzo[i][j];
    }
  return 0;
}

I have no trouble. If I try to write the method for an object:

- aggiornaFeedHist
{
  int i, j;
  int numCol[5]={8,8,8,9,10};
  char *Ipezzo[5];
  char **labelsHistp;

  labelsHistp = [[self getZone] alloc: (sizeof (char *) * 5)];
    for(i=0;i<5;i++)
      {
         Ipezzo[i]=[[self getZone] alloc: (sizeof (char) * 2)];
         labelsHistp[i]=[[self getZone] alloc: (sizeof (char) * numCol[i])];
         labelsHistp[i]="";
      }
  for(i=0;i<5;i++)
    {
      Ipezzo[i]="x=";
      for (j=0;j<2;j++)
           labelsHistp[i][j]=Ipezzo[i][j]; ***
    }

  return self;
}

after *** I have segmentation fault.Why? Could somebody help me?
address@hidden





















reply via email to

[Prev in Thread] Current Thread [Next in Thread]