• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: objc_method_list structure?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objc_method_list structure?


  • Subject: Re: objc_method_list structure?
  • From: Dustin Voss <email@hidden>
  • Date: Thu, 11 Nov 2004 19:23:07 -0800

On 11 Nov, 2004, at 6:02 PM, Tim Conkling wrote:

struct objc_method_list
{
	struct objc_method_list *obsolete;
	int method_count;
	struct objc_method method_list[1];
};

According to the documentation, the method_list field in the above structure is supposed to be "An array of objc_method data structures." I'm not sure what should go in the [0] index and what should go in the [1] index in order to make this array...

This is a common C technique. How it works is, the array is not actually 1 element long. It is however long method_count says. method_list is actually a pointer to a block of contiguous memory that is treated as an array. The memory block is (method_count * sizeof(objc_method)) bytes long. You can address the elements like method_list[0], etc., all the way up to, but not including, method_count, just like any array.


To create this, make an appropriately-sized memory block, fill it as if it were an array, and set method_count to the number of elements and method_list to the address of the block.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: objc_method_list structure?
      • From: Tim Conkling <email@hidden>
References: 
 >objc_method_list structure? (From: Tim Conkling <email@hidden>)

  • Prev by Date: Strategy for NSTimer
  • Next by Date: Re: objc_method_list structure?
  • Previous by thread: Re: objc_method_list structure?
  • Next by thread: Re: objc_method_list structure?
  • Index(es):
    • Date
    • Thread