File: sleep_test.c

package info (click to toggle)
uthash 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,788 kB
  • sloc: ansic: 9,838; makefile: 178; perl: 88; sh: 37; cpp: 30
file content (32 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "uthash.h"
#include <stdlib.h>   /* malloc */
#include <stdio.h>    /* printf */
#include <unistd.h>   /* getpid */

typedef struct example_user_t {
    int id;
    int cookie;
    UT_hash_handle hh;
} example_user_t;

int main()
{
    int i;
    example_user_t *user, *users=NULL;

    /* create elements */
    for(i=0; i<10000; i++) {
        if ( (user = (example_user_t*)malloc(sizeof(example_user_t))) == NULL) {
            exit(-1);
        }
        user->id = i;
        user->cookie = i*i;
        HASH_ADD_INT(users,id,user);
    }

    printf("pid: %u\n", (unsigned)getpid());
    /* printf("sig: %p\n", &users->hh.tbl->signature); */
    /* printf("bbv: %p\n", &users->hh.tbl->bloom_bv); */
    sleep(60*10);
    return 0;
}