Questions tagged [alloc]
207 questions
-1
votes
1 answer
Invalid read/write of size when alloc
So I tried to make easy alloc and then free allocated memory but valgrind writes these errors.
#include
#include
#include
int main()
{
char* area=(char*)malloc(3);
strcpy(area, "lal");
printf("%s\n",area);
…

ewazdomu
- 39
- 5
-1
votes
3 answers
why double free or corruption?
Every 1 second, function works.
my system the linux. Runs suddenly dies.
-----global-------
static int arrayNum[33000];
-------------------
function(){
unsigned short int** US_INT;
try{
US_INT= new unsigned short int*[255];
…

OMG_Soruce
- 96
- 1
- 2
- 9
-1
votes
1 answer
Objective C - How to call class methods without allocating and initializing an object
I'm new to Objective-C and I'm finding the syntax of valid Objective-C code hard to understand. For example, all objects are normally allocated and initialized using the MyClass *myObject = [[MyClass alloc] init]; syntax. However, in the example…

Confused Programmer
- 31
- 5
-1
votes
4 answers
Declaration and Allocation
I have some doubts about C allocations.
#include
typedef struct MyStruct {
char CharsInMyStruct[50];
} MyStruct;
int main(void) {
struct MyStruct * s;
s = malloc(100 * sizeof *s);
}
I was told that the allocation is…

user3574984
- 453
- 2
- 6
- 16
-1
votes
1 answer
Obj-c: Allocating a subclassed object from another object and releasing
While profiling my app with Instruments, I found a leak with an array that I allocated. To my knowledge I was doing this correctly, but it looks like something is wrong.
Let's say I have three classes, class M, A and B.
Subclass B has a unique…

Chewie The Chorkie
- 4,896
- 9
- 46
- 90
-1
votes
1 answer
Difference between [[UIImageView new] init] and [[UIImageView alloc] init]
I am just wonder what is the difference between [[UIImageView new] init] and [[UIImageView alloc] init] .
is memory allocated in [[UIImageView new] init] as well ?

Muhammad Saad Ansari
- 1,748
- 3
- 13
- 20
-2
votes
1 answer
Why does programm throws double free detected in tcache 2 while using single linked list
Im trying to create function to delete from single-linked list all elements with value smaller as next (following) element value. For some reason programm throws "free():double free detected in tcache 2". What is wrong with my function ?
list is not…

Arsenyev01
- 1
- 3
-2
votes
1 answer
Equivalent of Obj-C alloc statement in swift
I want to use This library in swift. It's written in Obj-C.
I've added header and Bridging and etc, now, I don't know what is equivalent of this statement :
//Color did change block declaration
NKOColorPickerDidChangeColorBlock…

Reza_Rg
- 3,345
- 7
- 32
- 48
-2
votes
1 answer
how to mange memory with properties
I am new to iOS so trying to understand memory management.
I have a .h File which contains a property and i want to use that var in some function.
@property (nonatomic, retain) NSMutableArray *myArray;
then in my .m File i have some function…

Vinay Chopra
- 3
- 4
-2
votes
2 answers
create a queue in a specific location on the disk c++
How do I create a queue in c++ that will be allocated on a specific path?
I mounted ramfs on /mnt/ram/ which is a RAM folder rather than a disk , and would like the queue to be there, so the performance would be better than if the queue were…

Alon_T
- 1,430
- 4
- 26
- 47
-3
votes
1 answer
What is difference between Dynamic allocation and Static Allocation
What is difference between Dynamic memory allocation and Static memory Allocation?
I don't understand this code:
int arrA[20];
int* arrB = new int [20];
What is the difference between those two lines?
Why does Dynamic allocation have array size?
-3
votes
2 answers
Use of undeclared identifier alloc?
When I try to create an instance of a custom class, using this code...
PlayerTurn *playerTurn = [[alloc] init];
...inside the definition of a method in my View Controller .m file, I get this error:
"use of undeclared identifier alloc"
Can someone…

Dave
- 81
- 7