[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <877gsohd0i.fsf@sejong.aot.lge.com>
Date: Fri, 24 Aug 2012 18:09:49 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Bernhard Rosenkraenzer <bernhard.rosenkranzer@...aro.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCHv2 1/1] perf: Port to Android
On Fri, 24 Aug 2012 18:02:24 +0900, Namhyung Kim wrote:
> On Thu, 23 Aug 2012 17:01:52 +0200, Bernhard Rosenkraenzer wrote:
[SNIP]
>> +
>> +/* Assorted functions that are missing from Bionic */
>> +static void psignal(int sig, const char *s)
>> +{
>> + if(sig >= 0 && sig < NSIG) {
>> + if(s)
>> + fprintf(stderr, "%s: %s\n", s, sys_siglist[sig]);
>> + else
>> + fprintf(stderr, "%s\n", sys_siglist[sig]);
>> + } else {
>> + if(s)
>> + fprintf(stderr, "%s: invalid signal\n", s);
>> + else
>> + fputs("invalid signal\n", stderr);
>> + }
>> +}
>> +
>> +static ssize_t getline(char **lineptr, size_t *n, FILE *stream)
>> +{
>> + size_t ret = 0;
>> +
>> + if (!lineptr || !n || !stream)
>> + return -1;
>> +
>> + if(!*lineptr) {
>> + *n = 128;
>> + *lineptr = (char*)malloc(*n);
>> + if(!*lineptr)
>> + return -1;
>> + }
>> +
>> + while(!feof(stream) && !ferror(stream)) {
>> + int c;
>> + if(ret == *n) {
>> + *n += 128;
>> + *lineptr = (char*)realloc(*lineptr, *n);
>> + if(!*lineptr) {
>> + *n = 0;
>> + return -1;
>> + }
>> + }
>> + c = fgetc(stream);
>> + if(c == EOF)
>> + break;
>> + *lineptr[ret++] = c;
>> + if(c == '\n')
>> + break;
>> + }
>> + *lineptr[ret] = 0;
>> + return ret;
>> +}
>
> And above two functions can be moved too somehow.
I meant it can be moved to the .c file.
Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists