Hao's dis

Forum rules
- Ask questions about or share code from languages other than Source Engine scripting.
- Start new topic titles with the code language in brackets (i.e. [C#], [C++], [PHP], etc.)
[GR]doodleninja
1000+ Posts
1000+ Posts
Posts: 1086
Joined: Mon Feb 27, 2012 11:08 am

Hao's dis

Post by [GR]doodleninja »

Code: Select all

struct group_info init_groups = { .usage = ATOMIC_INIT(2) };

struct group_info *groups_alloc(int gidsetsize){

    struct group_info *group_info;

    int nblocks;

    int i;



    nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;

    /* Make sure we always allocate at least one indirect block pointer */

    nblocks = nblocks ? : 1;

    group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);

    if (!group_info)

        return NULL;

    group_info->ngroups = gidsetsize;

    group_info->nblocks = nblocks;

    atomic_set(&group_info->usage, 1);



    if (gidsetsize <= NGROUPS_SMALL)

        group_info->blocks[0] = group_info->small_block;

    else {

        for (i = 0; i < nblocks; i++) {

            gid_t *b;

            b = (void *)__get_free_page(GFP_USER);

            if (!b)

                goto out_undo_partial_alloc;

            group_info->blocks[i] = b;

        }

    }

    return group_info;



out_undo_partial_alloc:

    while (--i >= 0) {

        free_page((unsigned long)group_info->blocks[i]);

    }

    kfree(group_info);

    return NULL;

}



EXPORT_SYMBOL(groups_alloc);



void groups_free(struct group_info *group_info)

{

    if (group_info->blocks[0] != group_info->small_block) {

        int i;

        for (i = 0; i < group_info->nblocks; i++)

            free_page((unsigned long)group_info->blocks[i]);

how is this?
Nicdel
Server Admin
Posts: 2417
Joined: Sun Apr 11, 2010 4:50 am

Re: Hao's dis

Post by Nicdel »

If you feel cool just because you posted a part of the linux kernel, you're a faggot.
Ingame: -[SaD]- Nico

Image
[GR]doodleninja
1000+ Posts
1000+ Posts
Posts: 1086
Joined: Mon Feb 27, 2012 11:08 am

Re: Hao's dis

Post by [GR]doodleninja »

http://www.hackertyper.com/

type random shit. it will turn into code
Nicdel
Server Admin
Posts: 2417
Joined: Sun Apr 11, 2010 4:50 am

Re: Hao's dis

Post by Nicdel »

[GR]doodleninja wrote:http://www.hackertyper.com/

type random shit. it will turn into code
Always the same code. From the linux kernel.

http://www.hackertyper.com/code.txt
Ingame: -[SaD]- Nico

Image
[GR]doodleninja
1000+ Posts
1000+ Posts
Posts: 1086
Joined: Mon Feb 27, 2012 11:08 am

Re: Hao's dis

Post by [GR]doodleninja »

ik. where did you learn so much 'bout pc
Nicdel
Server Admin
Posts: 2417
Joined: Sun Apr 11, 2010 4:50 am

Re: Hao's dis

Post by Nicdel »

[GR]doodleninja wrote:ik. where did you learn so much 'bout pc
By myself.
Ingame: -[SaD]- Nico

Image
User avatar
killman2639
Former Server Admin
Posts: 292
Joined: Mon Aug 23, 2010 8:41 pm

Re: Hao's dis

Post by killman2639 »

Nicdel wrote:
[GR]doodleninja wrote:ik. where did you learn so much 'bout pc
By myself.

Best way :ugeek:
Hi, I'm Reloaded. :)

Image

Code: Select all

[GR|CMX] Reelawded | Reloaded :  hi, im black
[GR|CMX] Reelawded | Reloaded :  shit
Disconnect: being black.
Disconnect: being black.
Jack
Former Server Admin
Posts: 1251
Joined: Fri Apr 09, 2010 4:01 pm
Location: Norway, Oslo

Re: Hao's dis

Post by Jack »

Code: Select all

public class QuickF 
  { public static void main(String[] args) 
    { int N = Integer.parseInt(args[0]);
      int id[] = new int[N];
      for (int i = 0; i < N ; i++) id[i] = i; 
      for( In.init(); !In.empty(); )
        { int p = In.getInt(), q = In.getInt();
          int t = id[p];
          if (t == id[q]) continue;
          for (int i = 0; i < N; i++)
            if (id[i] == t) id[i] = id[q];
          Out.println(" " + p + " " + q);
        }
    }
  }
-----
    int i, j, p = In.getInt(), q = In.getInt();
    for (i = p; i != id[i]; i = id[i]);
    for (j = q; j != id[j]; j = id[j]);
    if (i == j) continue;
    id[i] = j;
    Out.println(" " + p + " " + q);
-----
public class QuickUW
{ public static void main(String[] args) 
  { int N = Integer.parseInt(args[0]);
    int id[] = new int[N], sz[] = new int[N]; 
    for (int i = 0; i < N ; i++)
      { id[i] = i; sz[i] = 1; }
    for(In.init(); !In.empty(); )
      { int i, j, p = In.getInt(), q = In.getInt();
        for (i = p; i != id[i]; i = id[i]);
        for (j = q; j != id[j]; j = id[j]);
        if (i == j) continue;
        if (sz[i] < sz[j])
             { id[i] = j; sz[j] += sz[i]; }
        else { id[j] = i; sz[i] += sz[j]; }
        Out.println(" " + p + " " + q);
      }
  }
}	
-----
    for (i = p; i != id[i]; i = id[i])
      id[i] = id[id[i]];
    for (j = q; j != id[j]; j = id[j])
      id[j] = id[id[j]];

static int search(int a[], int v, int l, int r)
  { int i;
    for (i = l; i <= r; i++)
      if (v == a[i]) return i;
    return -1;
  }
-----
static int search(int a[], int v, int l, int r)
  { 
    while (r >= l)
      { int m = (l+r)/2;
        if (v == a[m]) return m;
        if (v < a[m]) r = m-1; else l = m+1;
      }
    return -1;
  }
omaigad, im a hacker now.
Spoiler
Show
and i got no idea what the fuck this shit is
Cookie
50+ Posts
50+ Posts
Posts: 99
Joined: Fri May 25, 2012 12:47 pm
Location: France

Re: Hao's dis

Post by Cookie »

[GR]doodleninja wrote:

Code: Select all

struct group_info init_groups = { .usage = ATOMIC_INIT(2) };

struct group_info *groups_alloc(int gidsetsize){

    struct group_info *group_info;

    int nblocks;

    int i;



    nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;

    /* Make sure we always allocate at least one indirect block pointer */

    nblocks = nblocks ? : 1;

    group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);

    if (!group_info)

        return NULL;

    group_info->ngroups = gidsetsize;

    group_info->nblocks = nblocks;

    atomic_set(&group_info->usage, 1);



    if (gidsetsize <= NGROUPS_SMALL)

        group_info->blocks[0] = group_info->small_block;

    else {

        for (i = 0; i < nblocks; i++) {

            gid_t *b;

            b = (void *)__get_free_page(GFP_USER);

            if (!b)

                goto out_undo_partial_alloc;

            group_info->blocks[i] = b;

        }

    }

    return group_info;



out_undo_partial_alloc:

    while (--i >= 0) {

        free_page((unsigned long)group_info->blocks[i]);

    }

    kfree(group_info);

    return NULL;

}



EXPORT_SYMBOL(groups_alloc);



void groups_free(struct group_info *group_info)

{

    if (group_info->blocks[0] != group_info->small_block) {

        int i;

        for (i = 0; i < group_info->nblocks; i++)

            free_page((unsigned long)group_info->blocks[i]);

how is this?
Image
User avatar
MAMALUIGI
50+ Posts
50+ Posts
Posts: 87
Joined: Thu Aug 25, 2011 12:11 am

Re: Hao's dis

Post by MAMALUIGI »

doodle ninja is like a newfag that stays a newfag forever. Ive been reading retarded topics and replies from this guy for about 6 months.
awesomedude
Former Server Admin
Posts: 804
Joined: Sun Jan 15, 2012 6:37 pm

Re: Hao's dis

Post by awesomedude »

MAMALUIGI wrote:doodle ninja is like a newfag that stays a newfag forever. Ive been reading retarded topics and replies from this guy for about 6 months.
Well you obviously haven't been reading enough. Don't comment on month-old threads.
Just for the record: I agree with you.
Shit happens
[GR]doodleninja
1000+ Posts
1000+ Posts
Posts: 1086
Joined: Mon Feb 27, 2012 11:08 am

Re: Hao's dis

Post by [GR]doodleninja »

Me too