Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type casting integers as pointers

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi

Is there a maximum integer I can safely typecast as a pointer or does it not matter?

I'm storing ids (currently 1 - 3500) in a TList as mylist.add(pointer(id)). I was just a bit worried in case I hit addresses that were being used by other apps.

lou
 
I don't think it matters. Typecasting doesn't usually generate any code. The compiler doesn't generate instructions to see if the pointer is an invalid address.

However, I don't think this is a good use of TList. Whilst it will work, this kind of coding has a habit of coming back and biting you hard when you need to modify your program at some future date.

I would guess you need to use/write a class for holding these ids or possibly use a dynamic array.

Andrew





 
hi Andrew

You're probably right, I'll change it to 'array of integer'. I'm just a bit of a fan of TLists and didn't give it much thought [smile2]

lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top