0 registered members (),
853
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
checking a BMAP pointer if it's empty
#182883
02/09/08 10:21
02/09/08 10:21
|
Joined: Aug 2005
Posts: 1,012 germany, dresden
ulf
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,012
germany, dresden
|
hey, the following situation... i have a bitmap pointer like this Code:
BMAP* b_dot = NULL; char* b_dot_file = "dot.tga";
//then i fill it like this
BMAP* bmapCheck(BMAP* source, char* file) { if (source == NULL) { source = bmap_create(file); } return(source); }
it gets filled the first time, but also the second and so on... so i produce some sort of filling the memory forever. so source is always == NULL but shouldn't it be filled the second time i run this function? right now its not and a new bitmap is created in memory everytime i rerun the function. it gets called like this from a particle function f.i. p.bmap=bmapCheck(b_dot, b_dot_file); thanks for any help.
Last edited by ulf; 02/09/08 10:32.
|
|
|
Re: checking a BMAP pointer if it's empty
[Re: Excessus]
#182887
02/09/08 14:01
02/09/08 14:01
|
Joined: Aug 2005
Posts: 1,012 germany, dresden
ulf
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,012
germany, dresden
|
thanks! but as for assigning b_dot i did already use the function exactely as you said:
p.bmap=bmapCheck(b_dot, b_dot_file);
but this does not work. using the BMAP** and *source idea did only lead to engine crashes and doesnt really work. (i did call it with b_dot=bmapCheck(&b_dot, b_dot_file); in this case)
Last edited by ulf; 02/09/08 14:09.
|
|
|
Re: checking a BMAP pointer if it's empty
[Re: ulf]
#182888
02/09/08 14:14
02/09/08 14:14
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Quote:
as for assigning b_dot i did use exactely as you said:
p.bmap=bmapCheck(b_dot, b_dot_file);
No you assign to p.bmap. I don't know what it is, but you should at least assign to b_dot too, since that is what you will pass as input the next time you call it: b_dot=bmapCheck(b_dot, b_dot_file);
Here is the (untested) code using a BMAP**. Does this crash? Code:
BMAP* b_dot = NULL; char* b_dot_file = "dot.tga";
//then i fill it like this
BMAP* bmapCheck(BMAP** source, char* file) { if (*source == NULL) { *source = bmap_create(file); } return(*source); } bmapCheck(&b_dot, b_dot_file); // now b_dot should point to the new bitmap
|
|
|
|