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. 


begin 0644 testvorbis2.d
M:6UP;W)T(&-L87ET96LN8RYA;'1Y<&5S.PII;7!O<G0 8VQA>71E:RYC+F%L
M97AT='EP97,[" II;7!O<G0 8VQA>71E:RYC+F%L.PII;7!O<G0 8VQA>71E
M:RYC+F%L8SL*:6UP;W)T(&-L87ET96LN8RYA;'5T.PH*:6UP;W)T('-T9"YC
M+G-T9&EO.PII;7!O<G0 <W1D+F,N<W1D;&EB.PII;7!O<G0 <W1D+F,N=&EM
M93L*:6UP;W)T('-T9"YC+FQI;G5X+FQI;G5X.R`O+R!I;B!D(&QI;G5X(&9I
M;&4*"F-O;G-T(&EN="!.54U33U520T53(#T ,3L*"D%,8F]O;&5A;B!3;W5R
M8V5)<U!L87EI;F<H04QU:6YT('-I9"D >PH)04QI;G0 <W1A=&4[" H):68H
M86Q)<U-O=7)C92AS:60I(#T]($%,7T9!3%-%*2![" D)<F5T=7)N($%,7T9!
M3%-%.PH)?0H*"7-T871E(#T 04Q?24Y)5$E!3#L*"6%L1V5T4V]U<F-E:78H
M<VED+"!!3%]33U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BAA;'5T3&]A9%9O<F)I<W` /3T 
M;G5L;"D >PH)"69R964H9&%T82D[" H)"69P<FEN=&8H<W1D97)R+"`B0V]U
M;&0 ;F]T($=E=%!R;V, )7-<;B(L" D)"6-A<W0H04QU8GET92`J*2`B86QU
M=$QO8616;W)B:7-?3$]+22(I.PH)"65X:70H+30I.PH)?0H*"7!R:6YT9B B
M86QU=%9O<F)I<W` ;F]T(&YU;&P 7&XB*3L*" EI9BAA;'5T3&]A9%9O<F)I
M<W`H=F]R8F)U9BP 9&%T82P <VEZ92D (3T 04Q?5%)512D >PH)"69P<FEN
M=&8H<W1D97)R+"`B86QU=$QO8616;W)B:7, 9F%I;&5D7&XB*3L*"0EE>&ET
M*"TR*3L*"7T*" EP<FEN=&8H(FQO861E9"!V;W)B:7-<;B(I.PH*"69R964H
M9&%T82D[" H)<')I;G1F*")F<F5E9"!D871A7&XB*3L*" EA;%-O=7)C95!L
M87DH('9O<F)S;W5R8V4 *3L*" EP<FEN=&8H(G!L87EI;F< 9FEL95QN(BD[
M" H)=VAI;&4H4V]U<F-E27-0;&%Y:6YG*'9O<F)S;W5R8V4I(#T]($%,7U12
M544I('L*"0ES;&5E<" Q*3L*"7T*" EA;&-$97-T<F]Y0V]N=&5X="AC;VYT


`
end
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