Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

GC is shit

Name: Anonymous 2012-01-09 14:49

Why don't compilers just automatically put frees in source code instead of collecting garbage at runtime?

Name: Anonymous 2012-01-09 14:51

Linear programming does that.

Name: Anonymous 2012-01-09 14:51

because garbage collection is an israeli conspiracy

Name: Anonymous 2012-01-09 14:52

Manual reference counting where free is called if the count is found to be zero, y/n?

Name: Anonymous 2012-01-09 14:53

>>4
guido approved!

Name: Anonymous 2012-01-09 15:02

Name: Anonymous 2012-01-09 15:31

/* C reference counting library */

typedef struct {
     size_t n;
     unsigned char data[];
} *Refcount;

#define ref_data(r) (void *)&(r)->data

#define ref_data_typed(T,r) *(T *)&(r)->data

Refcount ref_alloc(size_t size) {
     Refcount r = malloc(sizeof(int)+size);
     if (!r) return NULL;
     r->d = 0;
     return r;
}

Refcount ref_copy(Refcount d, Refcount s) {
     d = s;
     s->n++;
};

Refcount ref_delete(Refcount d) {
     d->n--;
     if (!d->n) free(d);
     d = NULL;
};

Name: Anonymous 2012-01-09 15:43

>>7
>>6
>>4
If it ain't Linear Lisp, it's crap.

Name: Anonymous 2012-01-09 16:10

>>7
is that in some way official because using a size in the sizeof(int) of the machine seems retarded, in
Refcount r = malloc(sizeof(int)+size);

Name: Anonymous 2012-01-09 16:13

That's reference counting, but not automatic memory management.

I.e, instead of

{
 obj = CreateSomeObject(..);
 // do something with obj
 // but don't forget to free the memory before a leak occurs!
 free(obj);
}

It should be, in an ideal world without GC and no free():

{
 obj = CreateSomeObject(...);
 // do something with obj
 // fuck free(), the compiler should auto-insert free(obj)
 // when the object is not in scope anymore.
}

Name: Anonymous 2012-01-09 16:15

>>9
I wrote that in 5 minutes, and I originally used int n and changed it to size_t n, but forgot to change the malloc size.

Name: Anonymous 2012-01-09 16:17

>>10
{
  SomeObject obj;
  InitSomeObj(&obj);
  // do something with obj
}


{
  SomeObject obj = DEFAULT_SOME_OBJ;
  // do something with obj
}

Name: Anonymous 2012-01-09 16:18

>>10
That's what non-standard functions like alloca() are for.

Name: Anonymous 2012-01-09 17:55

>>10
And how are you certain that obj is not stored in some data structure by the time that scope finishes?

Name: Anonymous 2012-01-09 18:23

>>14
In that case, you should allocate the object into local storage.

Name: Anonymous 2012-01-09 23:54

>>10

C++ has smart pointers and RAII for this work.

Name: Anonymous 2012-01-10 0:31

smart pointers
ass
RAII
shit

Name: Anonymous 2012-01-10 3:56

C++ has solved every problem in memory management. GC is obsolete.

Name: Anonymous 2012-01-10 12:04

>>18
Programmers have solved(and created) every problem in memory managment using C/ASM memory managment is now obsolete.

Name: Anonymous 2012-01-10 12:06

>>19
Jews have solved (and created) every problem in science using Kabbalah. Science is now obsolete.

Name: Anonymous 2012-01-10 12:31

Niggers have solved(and created) every problem using crack. Crack is now obsolete.

Name: Anonymous 2012-01-10 13:14

>>17
that's just.. ur opinion.. man.

Name: Anonymous 2012-01-10 14:56

>>20
Nazis have solved (and created) every problem in Jews using the Final Solution. Jews are now obsolete.

Don't change these.
Name: Email:
Entire Thread Thread List