Quote Originally Posted by User137
Try keep variable types the same on source and destination. Extra type conversions takes time and makes errors possible. Especially if you have
[pascal]var
source: smallint;
dest: word;
begin
source:=-1;
dest:=source; // Now dest would be something over 30000 i guess
// or vice versa, unsigned to signed can result in number go negative
// or larger type to small type can make the value looping like with mod
end;[/pascal]
You know what i mean...

And your code seems valid.
Well looking at the problem that way, I can see how I might go wrong.

I however would instead take the signed value into a local variable move that to another variable of the required sample data type and then copy that into the allocated data pointer.

So from pointer to different typecast pointer OR from variable to different type cast pointer I can see how it might mess up my values, BUT from variable to different typecast variable it shouldn't give me issues, right?