igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] How to test for initialisation?


From: Tamás Nepusz
Subject: Re: [igraph] How to test for initialisation?
Date: Tue, 21 Jan 2014 17:40:55 +0100

> How can I test whether an igraph_t variable has been initialised already?

This is a bit of a hack, but in the worst case you can try the following. 
Whenever you create an igraph_t on the stack or allocate an igraph_t on the 
heap, set all of its bytes to zero using memset(). When you initialize a graph 
using igraph_init, it is pretty sure that at least one of the bytes will be 
changed in the igraph_t structure, so in the worst case you can create a 
utility function that evaluates every single byte of an igraph_t and returns 
true if and only if all the bytes are zeros. (However, you should also make 
sure to call memset() again after an igraph_destroy() operation).

Now that I read it again, it seems even more horrible than before. Gabor’s 
solution is definitely much better, but if you don’t feel like introducing a 
myigraph_t for this purpose, this could be an alternative.

T.






reply via email to

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