[haiku-commits] Re: haiku: hrev46347 - src/kits/mail

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 11 Nov 2013 09:46:45 +0100

On 2013-11-11 at 09:40:04 [+0100], Stephan Aßmus <superstippi@xxxxxx> wrote:
> Hi,
> 
> On 11.11.2013 00:27, mattmadia@xxxxxxxxx wrote:
> > Commit:      c801b51ce8ca55a72e9d7ea61b047dbfd2f0aec2
> 
> >   BAttributedMailAttachment::SaveToDisk(BEntry *entry)
> >   {
> >       BString path = "/tmp/";
> > -    char name[B_FILE_NAME_LENGTH + 1] = "";
> > +    char name[B_FILE_NAME_LENGTH] = "";
> >       _data->FileName(name);
> 
> This looks still weird to me. One can initialize a char array like this?
> 
> What I am wondering is... "name" is a char pointer which points to a
> char buffer allocated on the stack. And after the assignment, doesn't it
> point to the empty char array *instead*? Maybe I've been programming too
> much Java lately.

http://stackoverflow.com/questions/201101/how-to-initialize-an-array-in-c

C arrays look very much like pointers, but in some cases they aren't. This 
is one such case.

-- 
Adrien.

Other related posts: