Page 1 of 1
Hao's dis
Posted: Tue May 29, 2012 10:26 am
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?
Re: Hao's dis
Posted: Tue May 29, 2012 11:28 am
by Nicdel
If you feel cool just because you posted a part of the linux kernel, you're a faggot.
Re: Hao's dis
Posted: Tue May 29, 2012 11:36 am
by [GR]doodleninja
http://www.hackertyper.com/
type random shit. it will turn into code
Re: Hao's dis
Posted: Tue May 29, 2012 11:39 am
by Nicdel
Always the same code. From the linux kernel.
http://www.hackertyper.com/code.txt
Re: Hao's dis
Posted: Tue May 29, 2012 11:44 am
by [GR]doodleninja
ik. where did you learn so much 'bout pc
Re: Hao's dis
Posted: Tue May 29, 2012 12:05 pm
by Nicdel
[GR]doodleninja wrote:ik. where did you learn so much 'bout pc
By myself.
Re: Hao's dis
Posted: Thu May 31, 2012 10:44 pm
by killman2639
Nicdel wrote:[GR]doodleninja wrote:ik. where did you learn so much 'bout pc
By myself.
Best way
Re: Hao's dis
Posted: Sat Jun 02, 2012 4:03 pm
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.
and i got no idea what the fuck this shit is
Re: Hao's dis
Posted: Mon Jun 04, 2012 11:15 am
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?
Re: Hao's dis
Posted: Thu Jul 12, 2012 5:33 am
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.
Re: Hao's dis
Posted: Thu Jul 12, 2012 5:50 am
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.
Re: Hao's dis
Posted: Fri Jul 13, 2012 5:53 am
by [GR]doodleninja
Me too