Questions tagged [alloc]

207 questions
0
votes
1 answer

In this string number method do I have to alloc every time it is called?

Using other answers in this forum I made this class method to tell if a string is a number. It works OK but do I have to alloc-init every time it is called? After all if this was not XCode4 that would constitute a memory leak wouldn't it? NB, I am…
nerak99
  • 640
  • 8
  • 26
0
votes
2 answers

Objective-C Property assignment without @property

I'm currently developing an iOS application which was started by another developer. Usually, I make a property for every instance variable (assign for int, bool etc. / retain for all classes). So in my projects, this line causes a leak: myVar =…
0
votes
1 answer

Initializing a subclass in objective c

I think that this may be impossible, but what I was trying to do write an static initializer in my super class "load" that will initialize even my subclasses. + (id) load { Class c = [self class]; NSString *cString = NSStringFromClass([self…
user1122069
  • 1,767
  • 1
  • 24
  • 52
0
votes
2 answers

How to reroot a tree which is allocated through malloc()

Below is a program which first build Binary tree from inorder and preorder and then find the node which contain largest balanced tree. My both function for Buildtree and IsBalanced is right. I am reading inorder and preorder from input.txt file;…
0
votes
1 answer

iOS >> How to Create a "Place Holder" Array for Objects that Were Not Yet Alloc/Init

In a certain view I have a bunch of AVAudioPlayer properties, each one is supposed to be played upon a certain user action. While the selected AVAudioPlayer is played, if another AVAudioPlayer was played - it should stop. To manage that, I've…
Ohad Regev
  • 5,641
  • 12
  • 60
  • 84
0
votes
1 answer

allocated too much memory

I try to do an app but I get a lot of crash an memory allocation, then I try to reduce all the code and clean it, now I get this e Why I get: Potential leak of an object allocated on line 101 and stored into 'livello' - (id)…
francesco.venica
  • 1,703
  • 2
  • 19
  • 54
0
votes
2 answers

NSMutable Array won't alloc, remains nil

A XML parser is trying to alloc its delegate's NSMutable array called masterCodeList. From the following code, you'll see that this fails. (I am a total newbie.) if (dataController.masterCodeList == nil){ dataController.masterCodeList…
AlexMath
  • 567
  • 1
  • 6
  • 16
0
votes
2 answers

Objective C: switch inside loop - how to avoid (potential) memory leak

I have a for loop where at the beginning an NSObject "value" is declared and then a switch statement within "value" is actually created. "value" then can be an NSNumber, an NSDate, an NSData, an NSString or nil. This is the code: for (int i = 0; i <…
user1360618
0
votes
2 answers

iOS - App crashes Garbagecollector's fault?

My team and I are working on a quiz app and we have 1 view and we simply reload the text on the labels and buttons. Now when we start the quiz there are 2 loops which load the questions and answeres from a database. In those loops we initialize…
oybcs
  • 327
  • 1
  • 4
  • 14
0
votes
3 answers

static method objective c - init once

I want to class that should be initialized only once and returns some value which was computed the first time. Is below the right approach ? @property (nonatomic, retain) NSString *userAgent; @implementation UserAgent @synthesize userAgent =…
i_raqz
  • 2,919
  • 10
  • 51
  • 87
-1
votes
2 answers

Qsort array of structs

I have an array of structs that I'm adding entries into typedef struct card { char* name; } card_t; These are the names in the file: Stolen by the Fae, Eternal Isolation, Corpse Knight, Orzhov Enforcer I have a qsort function that is supposed…
csDreamer
  • 11
  • 3
-1
votes
2 answers

Pointers,structure C

How can I work with the structure if i pass structure like parameter function ** ? typedef struct TQueue { ... int m_Len; }TQUEUE; void nahraj(TQUEUE **tmp) { tmp[5]->m_Len = 7; } int main (void) { TQUEUE *tmp; tmp =…
Aaron7
  • 277
  • 2
  • 10
-1
votes
2 answers

Alloc in programming language C

I am using the XDK Bosch Sensor for a project which is programmed in C. The idea is that the XDK should be able to connect to another network. SSID and password are sent via MQTT. It is already possible to connect the XDK to a network at…
JayJay
  • 43
  • 2
  • 13
-1
votes
1 answer

Overriding C++ STL allocator function to wrap it as threadsafe

My legacy C++ codebase is failing in a multithreaded execution scenario when two threads are concurrently tries to allocate memory for STL vector. The stacktrace of two threads are given below. ----------------- lwp# 4 / thread# 4 …
Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69
-1
votes
2 answers

When the class creates an object through the alloc method, does the object's reference count change to 1?

When we call alloc with a Class, Whether the object's reference count will be 1. For example: NSObject *obj = [NSObject alloc];,After this line of code is executed, the reference count of the object is 0 or 1? I read the source code, I can't find…
1 2 3
13
14