TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Herman Schonfeld
from: William McBrine
date: 1998-10-07 12:28:04
subject: Re: void pointers

-=> Herman Schonfeld wrote to All <=-

 HS> list = (void *)malloc(num_entries * sizeof(void *))
            ^^^^^^^^ This is redundant (malloc already returns a void *)

 HS> In the code I must determine these structures on the fly so as a rule
 HS> of thumb each structure's first member is a char, which is supposed
 HS> to determine it's type. I thought I could just do a simple cast to
 HS> the structure+1 (the extra byte is where the TYPE lies) and hence
 HS> determine what the structure is.

In the example code that followed, you showed the TYPE identifier as the
first character of each structure. There should be no additional offset,
then -- no "+1".

 HS> sizeof(char)

sizeof(char) is always 1; sizeof() measures in terms of char.

... Computer Hacker wanted. Must have own axe.
--- MultiMail/Linux v0.19
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 810 639/252
SEEN-BY: 670/218
@PATH: 106/2000 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.