[LLVMdev] Imprecise description of malloc instruction

Gabor Greif gabor at mac.com
Thu Feb 7 11:51:00 CST 2008


Hi all,

Quoting <http://llvm.org/docs/LangRef.html#i_malloc>:

  The 'malloc' instruction allocates sizeof(<type>)*NumElements bytes of
  memory from the operating system and returns a pointer of the appropriate type
  to the program. If "NumElements" is specified, it is the number of elements allocated.


Obviously this does not say that the default for NumElements is one.
Even obvious assumptions should be *explicit* in a spec :-)

May I reword as:

  The 'malloc' instruction allocates sizeof(<type>)*NumElements bytes of
  memory from the operating system and returns a pointer of the appropriate type
  to the program. If "NumElements" is specified, it is the number of elements allocated,
  otherwise "NumElements" is defaulted to be one.

?

Cheers

	Gabor


More information about the LLVMdev mailing list