I'm getting the oddest behaviour on Solaris (2.6) machines in
NSProcessInfo(_gnu_process_args). The code is essentially

    NSMutableArray      *keys = [NSMutableArray new];

    for {each environment variable...}
       [keys addObject: [NSString stringWithCString: {some C string}]];

The default initializer creates an array with capacity 1, so there is a
lot of realloc'ing the array early on. On the third realloc
(capacity==4), the actual CONTENTS of the first three values of the
array change! As if,

a[0] = 1; a[1] = 2; a[2] = 3; a[3] = 4

becomes

a[0] = 45345; a[1] = 0; a[2] = 0; a[3] = 4;

simply due to a realloc of a (in fact a[0] takes on the value of &a[4]).
Does anyone have any ideas what would cause this? Solaris has
problems with word alignment, but I don't see that happening here.
Just changing  the initialization to 

    NSMutableArray      *keys = [[NSMutableArray alloc]
initWithCapacity: 8];

fixes the problem
-- 
Adam Fedor, Digital Optics            | Fudd's law of opposition: Push
[EMAIL PROTECTED]  http://www.doc.com     | something hard enough, and it 
[EMAIL PROTECTED]  http://www.gnustep.org | will fall over.

_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to