Questions tagged [alloc]

207 questions
2
votes
4 answers

iPhone Autoreleasepool and allocations

I've been reading about autoreleasepool but there is a point which is a bit unclear to me. I have some functionality using threads that required seperate memory managment using autoreleasepool. In the following example is correct -(void)…
teo
  • 269
  • 1
  • 5
  • 11
2
votes
1 answer

c++ class library dynamic runtime allocation

Suppose I' have an interface class class foo_if_t { }; , a first library libfoo_orig.so with class foo_t which inherits from foo_if_t and has the following code: #include "foo_if.h" class foo_t : public foo_if_t{ private: int res; public: …
Riccardo Manfrin
  • 653
  • 1
  • 7
  • 15
2
votes
1 answer

Calling singleton object initiated from nib

I have an object which is initiated in my nib file. I want it to be a singleton but also accessible from code through [myClass sharedInstance];. Right now I have this: static myClass *singleton = nil; @implementation myClass + (myClass…
Jane
  • 51
  • 5
2
votes
1 answer

memory error in node JS (node::smalloc::Alloc)

I'm new to node Js, I've build a really simple server that send me back a zip file I request. It's all working but after some request a crash occur and i visualize this message on the terminal : FATAL ERROR: node::smalloc::Alloc(v8::Handle, size_t,…
Alberto Scampini
  • 798
  • 9
  • 27
2
votes
1 answer

C, realloc that fails if the allocation cannot grow IN PLACE

Is there a way to grow an array in C, but only if the memory can be grown in place (That is, fail to grow if the pointer needs to be changed)?
Exodist
  • 629
  • 5
  • 15
2
votes
1 answer

When initialize a pointer?

Generally what I have to do? I should always initialize ptr? char *ptr; ptr = malloc (10); OR char *ptr = NULL ; ptr = malloc (10); And in a function? void func(char **ptr) { *ptr = malloc(10); } int main() { char *ptr; /* OR char *ptr…
synth
  • 65
  • 5
2
votes
2 answers

Singleton Implementation. Blocking the alloc and init methods for external usage

I have a Class that I wish to implement as Singleton. I wish that the only way an Instance of this class may be created / accessed is via: +(MYClass*)sharedInstance method. alloc and init are called within the method implementation (of course). Is…
Ohad Regev
  • 5,641
  • 12
  • 60
  • 84
2
votes
2 answers

Are objects in Objective-C ever created on the stack?

As far as I understand, in C++ you can create objects on the stack: SomeClass object = SomeClass(); or on the heap: SomeClass *object = new SomeClass(); In Objective-C you always seem to create objects on the heap, as [SomeClass alloc] returns a…
Jawap
  • 2,463
  • 3
  • 28
  • 46
2
votes
1 answer

What is the purpose of LIFO memory allocation with an array in c?

#define ALLOCSIZE 10000 /* size of available space */ static char allocbuf[ALLOCSIZE]; /* storage for alloc */ static char *allocp = allocbuf; /* next free position */ char *alloc(int n) /* return pointer to n characters */ { if…
occamsrazor
  • 105
  • 8
2
votes
1 answer

Why Class produces warning and Class not, when using with alloc, init

I have two pices of code: for(Class tmpClass in config->ctxStorageClasses){ id stor = [[[tmpClass alloc] init] autorelease]; } and for(Class tmpClass in config->ctxStorageClasses){ id
The Tosters
  • 417
  • 3
  • 15
2
votes
1 answer

Allocating memory in Erlang C NIF

Why would one use void *enif_alloc_resource(ErlNifResourceType* type, unsigned size) as opposed to void *enif_alloc(size_t size) when trying to allocate memory from an Erlang C NIF? Reference does not specify much as to…
BAR
  • 15,909
  • 27
  • 97
  • 185
2
votes
0 answers

I get an EXC_BAD_ACCESS when creating UIManagedDocument

I am creating UIManagedDocument and I don't know why I get the error saying: Thread 1: EXC_BAD_ACCES code=1 address=0xdeadbeef The only thing in my code is the creation of this UIManagedDocument. This function is called in viewDidLoad: -…
Martin Verdejo
  • 1,229
  • 2
  • 13
  • 24
2
votes
2 answers

unsigned char alloc and free issue

I'm confused about one strange thing....I have an unsigned char array.... I allocate it using calloc and record some bytes data in it... but when I free this unsigned char and allocate it again, I see that it reserves the same address in memory…
Garnik
  • 423
  • 1
  • 6
  • 20
2
votes
1 answer

Under ARC, is there any difference between [[X alloc] initWith..] and [X xWith…]?

Take for example NSMutableArray: NSMutableArray* a1 = [[NSMutableArray alloc] initWithCapacity:10]; NSMutableArray* a2 = [NSMutableArray arrayWithCapacity:10]; Under manual reference counting, the second line returned an autoreleased object. Now…
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
2
votes
2 answers

Objective C typedef Enum memory management

Do I have to take care of memory when I deal with the enum ? This is where I declared my enum type. It is in another .h file This is where I attempt to declare variable After that Do I have o do something like that // This is where I declared my…