www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - argh! seg fault. - testvorbis2.d

reply clayasaurus <clayasaurus_member pathlink.com> writes:
hello, i'm in the process of trying to get openal to work with d. i've tried
converting the following code to D (i think this is where the problem lies,
because my printf's never get past the alutLoadVorbis function). 

c code...
typedef ALboolean (vorbisLoader)(ALuint, ALvoid *, ALint);
vorbisLoader *alutLoadVorbisp = NULL; 

..etc

alutLoadVorbisp(vorbbuf, data, size);

d code...
/* our vorbis extension */
alias ALboolean (vorbisLoader)(ALuint, ALvoid *, ALint);
vorbisLoader *alutLoadVorbisp = null;

..etc

alutLoadVorbisp(vorbbuf, data, size);

i've attached the whole file incase someone wants to take a look at what else
might be causing the problem. i also have code like this

if(stat(fname, &sbuf) == -1)
{
return -1;
}

printf("got stat info\n");

size = sbuf.st_size;
data = malloc(size);
if(data == null) {
exit(1);
}

in here that might be causing the problem. i dunno. any help would be highly
appreciated. thx. 
Jun 14 2004
next sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
 if(data == null) {

you probably want "data is null" since == will seg-v if data is null. Most of time == in C should be converted to "is" in D and != to either !== or !(.. is ..)
Jun 14 2004
parent reply clayasaurus <clayasaurus_member pathlink.com> writes:
In article <cakrar$1rgd$1 digitaldaemon.com>, Ben Hinkle says...
 if(data == null) {

you probably want "data is null" since == will seg-v if data is null. Most of time == in C should be converted to "is" in D and != to either !== or !(.. is ..)

well i changed == to is and != to !== , but it still seg faults in the same place.
Jun 14 2004
parent EricAnderton at yahoo dot com <EricAnderton_member pathlink.com> writes:
In article <caksmr$1u72$1 digitaldaemon.com>, clayasaurus says...
In article <cakrar$1rgd$1 digitaldaemon.com>, Ben Hinkle says...
 if(data == null) {

you probably want "data is null" since == will seg-v if data is null. Most of time == in C should be converted to "is" in D and != to either !== or !(.. is ..)

well i changed == to is and != to !== , but it still seg faults in the same place.

Just a thought: is "data" on the stack, or inside of a class? Maybe the *location* of data is no good, rather than just it's value. - Eric
Jun 14 2004
prev sibling parent Mike Parker <aldacron71 yahoo.com> writes:
clayasaurus wrote:

 hello, i'm in the process of trying to get openal to work with d. i've tried
 converting the following code to D (i think this is where the problem lies,
 because my printf's never get past the alutLoadVorbis function). 

 in here that might be causing the problem. i dunno. any help would be highly
 appreciated. thx. 
 
 

You might want to compile and run the C version as well, if you are using the latest version of OAL and haven't run it already. I've heard several reports of crashing since when using the latest.
Jun 14 2004