Question: I'm including this file to send email via swift mail
require\_once '../../../../../directory-above-root/swiftmailer/lib/swift\_required.php';

I'm getting the error require\_once(): open\_basedir restriction in effect. which I guess means it's trying to access a directory that is WAY to high up the directories and so can't be accessed.

Even though this path works when it is included in another file in the website it won't work when included in another file. The path should then become this to work properly: 
require\_once '../../directory-above-root/swiftmailer/lib/swift\_required.php';

Trouble is this file is included within a file that's included in this page so I need a way of pointing to the directory in an absolute way. (I hope this makes sense!)

The directory-above-root is a directory above the website directory (I use this because the file contains the login details for my email).

I think I need something like this:

define( 'ROOT\_DIR', dirname(**FILE**) );
require\_once ROOT\_DIR.'../directory-above-root/swiftmailer/lib/swift\_required.php';

Answer: 
look at the prototype of realloc:

```
void *realloc(void *ptr, size_t size);

```

its second arg is size, in bytes, and you are allocating an array of integers, you need the size of the whole array, not the number of elements, use this instead:

```
iArray=realloc(iArray, (counter+1) * sizeof(int));

```
That's because on each iteration, the realloc() only allocates one byte more than the value of `count`. I.e. in the very first iteration, you allocate one byte. But then you store the result of atoi(), which is the size of an `int`.