File: kml_utils.c

package info (click to toggle)
kernel-image-2.4.18-hppa 62.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 156,012 kB
  • ctags: 448,723
  • sloc: ansic: 2,586,445; asm: 145,047; makefile: 8,574; sh: 3,097; perl: 2,578; yacc: 1,177; tcl: 577; lex: 352; awk: 251; lisp: 218; sed: 72
file content (44 lines) | stat: -rw-r--r-- 999 bytes parent folder | download | duplicates (6)
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
33
34
35
36
37
38
39
40
41
42
43
44
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>

#include <linux/intermezzo_fs.h>
#include <linux/intermezzo_kml.h>


// dlogit -- oppsite to logit ()
//         return the sbuf + size;
char *dlogit (void *tbuf, const void *sbuf, int size)
{
        char *ptr = (char *)sbuf;
        memcpy(tbuf, ptr, size);
        ptr += size;
        return ptr;
}

static spinlock_t kml_lock = SPIN_LOCK_UNLOCKED;
static char  buf[1024];
char * bdup_printf (char *format, ...)
{
        va_list args;
        int  i;
        char *path;
        long flags;

        spin_lock_irqsave(&kml_lock, flags);
        va_start(args, format);
        i = vsprintf(buf, format, args); /* hopefully i < sizeof(buf) */
        va_end(args);

        PRESTO_ALLOC (path, char *, i + 1);
        if (path == NULL)
                return NULL;
        strcpy (path, buf);

        spin_unlock_irqrestore(&kml_lock, flags);
        return path;
}