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: 
Change this:

```
iArray=realloc(iArray,counter+1);

```

to this:

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

```

since you need to say to allocate space of what size. In your code you said allocate `counter + 1` space. *Of what?* Now, with my suggestion you allocate `counter + 1` times the size of where `iArray` points to (an `int`), which makes more sense, right? ;)

---

Check the [ref](http://www.cplusplus.com/reference/cstdlib/realloc/):

> 
> Changes the size of the memory block pointed to by ptr.
> 
> 
> The function may move the memory block to a new location (whose
>  address is returned by the function).
> 
> 
> The content of the memory block is preserved up to the lesser of the
>  new and old sizes, even if the block is moved to a new location. If
>  the new size is larger, the value of the newly allocated portion is
>  indeterminate.
> 
> 
> 

PS: Next time, format your code.
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`.