[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
make a pure string from a string literal
From: |
Dan Nicolaescu |
Subject: |
make a pure string from a string literal |
Date: |
Wed, 4 Nov 2009 08:01:18 -0800 (PST) |
There are a few build_string("STRING LITERAL") calls in emacs/src/*.c
The result is actually a constant string, so we could do:
Fpurecopy (build_string ("STRING LITERAL"))
but that creates another copy of "STRING LITERAL" in pure memory, we
already a have a perfectly good one in read only memory.
So how about adding:
Lisp_Object
make_pure_string_from_literal (const char *data)
{
Lisp_Object string;
struct Lisp_String *s;
s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
s->data = data;
s->size = strlen (data);
s->size_byte = -1;
s->intervals = NULL_INTERVAL;
XSETSTRING (string, s);
return string;
}
Then we can use make_pure_string_from_literal ("STRING LITERAL");
Any objections?
(better suggestions for the function name are welcome)
- make a pure string from a string literal,
Dan Nicolaescu <=