Re: contiguity of arrays

From: David Hopwood (david.nospam.hopwood_at_blueyonder.co.uk)
Date: 10/03/04


Date: Sun, 03 Oct 2004 04:24:30 GMT

David Hopwood wrote:
> Wojtek Lerch wrote:
>> What you seem to be saying is that for a region of memory to
>> constitute an array of four ints, it doesn't have to be declared with
>> a type that involves an array of four ints, or designated by an lvalue
>> with such a type, but nevertheless it must be declared with some
>> aggregate type ultimately consisting of four ints and no padding bytes
>> between them.
>
> Yes. This view is based on the definition of "array type" as being the type
> of any contiguous nonempty sequence of objects of the element type. In
> order to perform an access via a given pointer, say of type T, you need to be
> able to infer that it currently points to a region that *can* hold an object
> of type T. The memory allocation functions are a special case that return
> pointers to regions able to hold objects of any type.

... any type that is no larger than the allocated size, of course.

-- 
David Hopwood <david.nospam.hopwood@blueyonder.co.uk>


Relevant Pages

  • Re: "Parallel.For GC problems" and a solution.
    ... I think Dictionary(of dictionary(of small array of ints)) ... with the dictionaries holding arrays of keys, ... do not pass it a large array of things to process. ... With no breaks, memory goes crazy. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: contiguity of arrays
    ... >> What you seem to be saying is that for a region of memory to constitute ... >> an array of four ints, it doesn't have to be declared with a type that ... A struct type that consists of four ints ...
    (comp.lang.c)
  • Re: There is no sizeof in a managed language, right?
    ... I was trying to find how much memory is taken up by an array of ints, ... With references and managed languages, what do you use to figure this ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: So slow Tcl :(
    ... >pure-Tcl program relied too heavily on virtual memory). ... Oh, you're using short ints? ... it'd be a major saving too on a big array. ... arrays by arranging for numeric objects to be shared. ...
    (comp.lang.tcl)
  • Re: Fast string operations
    ... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)