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

Pages: 1-

WEEKLY CHALLENGE

Name: Anonymous 2010-07-24 6:51

implement malloc() using the C programming language.

Name: Anonymous 2010-07-24 7:02

void *malloc(size_t size) { return sbrk(size); }

What do I win?

Name: Anonymous 2010-07-24 7:04

>>1
TRICK CHALLENGE.

Name: overriding a shit thread 2010-07-24 7:23

Weekly Challenge: Programmatically convert any1 string of digits, such as "1234567" to word form, "one million, two hundred thirty-four thousand, five hundred sixty-seven"

Here is mine: http://codepad.org/gyqbaKxx

Criticize my code.  I know it sucks anus.  Submit your own versions as well.

_____________________________________
1. Up to 18 significant digits is fine.

Name: Anonymous 2010-07-24 7:37

>>2
you will fuck it up once you reach the page end.

Name: Anonymous 2010-07-24 8:08

>>4
This isn't the standard /prague/ thread override.

Name: Anonymous 2010-07-24 8:09

>>5
Please clarify. I have a bet with myself and I'm trying to determine whether I've won or lost just now.

Name: Anonymous 2010-07-24 8:52

void *malloc(size_t n) { return 0; }

Name: Anonymous 2010-07-24 8:58

>>7
as far as i know (s)brk only sets the end of the current data page. when you reach the end you will get a segfault.

but dont take my word on that, im not so sure.

Name: Anonymous 2010-07-24 9:00

>>8
Fact: This is a compliant implementation of malloc().  The C standard doesn't say that malloc() must ever succeed.

Name: Anonymous 2010-07-24 9:06

>>10
If the space cannot be allocated, a null pointer is returned.
Arguably this implies you cannot just fail every time, but actually need to check if "space can be allocated".

Name: Anonymous 2010-07-24 9:10

>>9
No, I don't think that's right. Especially that bit about the segfault... where did that come from?

>>10
Correct. It's better than >>2 in terms of compliance.

I basically lost the bet. I was expecting someone would complain about >>2 failing to do something that isn't required before anyone points out that it doesn't return null on failure, but >>8,10 is good enough.

Name: Anonymous 2010-07-24 9:57

void* malloc(size_t size)
{
    /* Create file with random name, `size' large. */
    /* mmap file. */
    /* Return memory area. */
}

/* Implementation of free using munmap and unlink. */

Name: Anonymous 2010-07-24 10:11

>>13
mmap is how most mallocs work. You know you don't need the file, right?

Name: Anonymous 2010-07-24 10:40

would you like to fondle my anus?

Name: 9 2010-07-24 10:48

>>12
>>9
No, I don't think that's right. Especially that bit about the segfault... where did that come from?

obviously, since you reference a memory region which you have no access rights to.

what i said must be correct, given that memory is handled pagewise and you cannot just access the next address without risking corrupting memory (not to mention that it has to be in the ldt).

correct me if im wrong.

Name: Anonymous 2010-07-24 10:54

>>14
Obviously, duuuuuuuuh.

Name: Anonymous 2010-07-24 12:10

>>16
For starters [s]brk is a syscall and isn't going to generate a segfault. Maybe if you try to access the memory after a failure sure, but that's your doing, not mine.

Name: Anonymous 2010-11-27 5:33

Name: Anonymous 2010-12-17 1:25

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-04 15:27

Name: Anonymous 2011-02-17 19:53

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