Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-23-2010, 03:54 PM   #2 (permalink)
bkl1989
Registered Member
 
Join Date: Apr 2010
Posts: 3
bkl1989 is on a distinguished road
Talking

Okay, here was the issue: I was reallocating that array of uitextviews like this:
Code:
//remotePairToS: top of the stack. 
//remotePairSize: size of the stack
//remotePairAlloc: amount of space to add each time stack is full

    if (remotePairToS == remotePairSize) { //if the stack is full...

        remotePairSize += remotePairAlloc;

        UITextView **tempRemoteNameView = malloc(sizeof(UITextView *) * remotePairSize);
        
        for (int i = 0; i < remotePairToS; ++i)
            tempRemoteNameView[i] = remoteNameView[i];
        
        free(remoteNameView);

        remoteNameView = tempRemoteNameView;
    }
And the remotePairAlloc, via another bug, was being set to zero. I know, I know, there are classes for this. Don't bother with a lecture about classes.
So, the stack was being reallocated successfully, but not increased in size. The top-of-stack value naturally reflected bad memory, and I was writing to it.
You might say that this has nothing to do with the initialization of the object in question. Well, it doesn't! The code doesn't interact at all. But, somehow, this was causing the problem. There's a lesson in this: use the classes that they give you as often as you can, and if you write to bad memory, the most vicious bugs will emerge, and you will be on the verge of killing yourself before you solve them.
bkl1989 is offline   Reply With Quote
 

» Advertisements
» Online Users: 400
18 members and 382 guests
baja_yu, bignoggins, chemistry, Domele, Duncan C, firecall, HowEver, ilmman, jaychoupham, jbro, Jenfrag, Karl6669, krisk, matador1978, n00b, NSString, Oral B, SuperDietGenius
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,559
Threads: 94,079
Posts: 402,742
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Jenfrag
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:17 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.