comparison src/alloc.c @ 46459:0a9cbcbdbe45

(xstrdup, make_string, make_unibyte_string) (make_multibyte_string, build_string): String pointer args now point to const.
author Ken Raeburn <raeburn@raeburn.org>
date Tue, 16 Jul 2002 19:47:52 +0000
parents b12a32662433
children b80760a75295
comparison
equal deleted inserted replaced
46458:7e33dc6a6f56 46459:0a9cbcbdbe45
573 573
574 /* Like strdup, but uses xmalloc. */ 574 /* Like strdup, but uses xmalloc. */
575 575
576 char * 576 char *
577 xstrdup (s) 577 xstrdup (s)
578 char *s; 578 const char *s;
579 { 579 {
580 size_t len = strlen (s) + 1; 580 size_t len = strlen (s) + 1;
581 char *p = (char *) xmalloc (len); 581 char *p = (char *) xmalloc (len);
582 bcopy (s, p, len); 582 bcopy (s, p, len);
583 return p; 583 return p;
1755 of characters from the contents. This string may be unibyte or 1755 of characters from the contents. This string may be unibyte or
1756 multibyte, depending on the contents. */ 1756 multibyte, depending on the contents. */
1757 1757
1758 Lisp_Object 1758 Lisp_Object
1759 make_string (contents, nbytes) 1759 make_string (contents, nbytes)
1760 char *contents; 1760 const char *contents;
1761 int nbytes; 1761 int nbytes;
1762 { 1762 {
1763 register Lisp_Object val; 1763 register Lisp_Object val;
1764 int nchars, multibyte_nbytes; 1764 int nchars, multibyte_nbytes;
1765 1765
1776 1776
1777 /* Make an unibyte string from LENGTH bytes at CONTENTS. */ 1777 /* Make an unibyte string from LENGTH bytes at CONTENTS. */
1778 1778
1779 Lisp_Object 1779 Lisp_Object
1780 make_unibyte_string (contents, length) 1780 make_unibyte_string (contents, length)
1781 char *contents; 1781 const char *contents;
1782 int length; 1782 int length;
1783 { 1783 {
1784 register Lisp_Object val; 1784 register Lisp_Object val;
1785 val = make_uninit_string (length); 1785 val = make_uninit_string (length);
1786 bcopy (contents, SDATA (val), length); 1786 bcopy (contents, SDATA (val), length);
1792 /* Make a multibyte string from NCHARS characters occupying NBYTES 1792 /* Make a multibyte string from NCHARS characters occupying NBYTES
1793 bytes at CONTENTS. */ 1793 bytes at CONTENTS. */
1794 1794
1795 Lisp_Object 1795 Lisp_Object
1796 make_multibyte_string (contents, nchars, nbytes) 1796 make_multibyte_string (contents, nchars, nbytes)
1797 char *contents; 1797 const char *contents;
1798 int nchars, nbytes; 1798 int nchars, nbytes;
1799 { 1799 {
1800 register Lisp_Object val; 1800 register Lisp_Object val;
1801 val = make_uninit_multibyte_string (nchars, nbytes); 1801 val = make_uninit_multibyte_string (nchars, nbytes);
1802 bcopy (contents, SDATA (val), nbytes); 1802 bcopy (contents, SDATA (val), nbytes);
1843 /* Make a string from the data at STR, treating it as multibyte if the 1843 /* Make a string from the data at STR, treating it as multibyte if the
1844 data warrants. */ 1844 data warrants. */
1845 1845
1846 Lisp_Object 1846 Lisp_Object
1847 build_string (str) 1847 build_string (str)
1848 char *str; 1848 const char *str;
1849 { 1849 {
1850 return make_string (str, strlen (str)); 1850 return make_string (str, strlen (str));
1851 } 1851 }
1852 1852
1853 1853