As lance said, A null pointer is a pointer whose value is zero.
So what's the big deal then and why give it a special name?
A null pointer in many languages is a dangerous thing. Pointers point
to addresses in memory and if you have ever tried accessing address
space zero you will know that an exception always occurs. Some languages
will ignore requests to use null pointers and others will let you
go ahead and crash the system. I am not sure about PB as I am very
careful about using uninitialised pointers.
So you see, A null pointer has great significance.
regards
Trevor
------------------
Announcement
Collapse
No announcement yet.
Finding the end of data (Null pointers?)
Collapse
X
-
The Win API may be of some help here (caveat follows)..
The IsBadReadPtr, IsBadWritePtr, IsBadStringPtr and a couple of other IsBadxxxPtr functions will tell you if your process has access to the memory at that location.
But...
Just because your application has the specified access does not necessarily mean it is part of the data item; that is, if different data are allocated contiguously, what you might think is "more of item one" is actually "start of item 2."
There is an option which may work for passed parameters:
From the Win32 help file:
The GlobalHandle function retrieves the handle associated with the specified pointer to a global memory block.
HGLOBAL GlobalHandle(
LPCVOID pMem // pointer to the global memory block
);
Then use:
The GlobalSize function retrieves the current size, in bytes, of the specified global memory object.
DWORD GlobalSize(
HGLOBAL hMem // handle to the global memory object
);
I have not tested this, but it sure looks promising. (Although I had to use this in the "other" direction. An application I interface to requires a pointer to an allocated (and locked)memory block (Hey, I didn't design this!). To unit test it outside the application I had to do exactly this so I could simulate what the application does, namely GlobalUnlock + GlobalFree).
BUT (AGAIN)..
As long as you get the offset and size of the data, Lance's suggestion to get the number of elements is a lot easier to implement.
My Point: Windows(r) provides a lot of services which can help.
The API is worth a little study from time to time.
MCM
Leave a comment:
-
-
Borje,
Nice idea! thx I will test that and let you know ...
------------------
Kind Regards
Mike
Leave a comment:
-
-
Looking back at your previous posting about this DLL, you get both
offset and array size as DWORD's. So, maybe wArraySize \ 4 will give
you number of elements..?
------------------
Leave a comment:
-
-
I'm sorry but I can't help with the TradeStation data issues, but I can tell you that a Null Pointer is a pointer whose value is zero - that is, it is an "uninitialized" pointer.
For example:
Code:DIM x AS LONG POINTER, y AS LONG ' at this point, "x" is a null pointer since it is set to zero x = VARPTR(y) ' at this point, "x" is a valid pointer. x = 0 ' at this point, "x" is a null pointer since it is set to zero
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
-
Finding the end of data (Null pointers?)
TradeStation loads market data into memory in the form of some kind of array where the elements are:
Open
High
Low
Close
Volume
OpenInterest
Each day is drawn on a chart as a "candlestick" consisting of an open, high, low and close.
Depending on how much data I have loaded into TS I will see a number of bars on the chart that show me price action.
The elkit32.dll basically gives me access to all variables in EL including arrays in the form of a pointer and an offset.
eg:
lpClose
A pointer to a Close array element in EasyLanguage.
nOfs
Specifies the bar offset. The offset is backwards if Ofs is positive or forward if Ofs is negative.
The Offset allows me traverse the data in memory foreward or backwards from any given bar that i call my Dll from.
Thats all fine if you know how many bars you have. I dont.
So I want to go fishing. I want to find the last bar, or the last "close" in memory. There is no documentation about what exists at the end of the data, if anything.
What should I look for?
What is a Null pointer anyway?
------------------
Kind Regards
MikeTags: None
-
Leave a comment: