[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/18] output: New function text_item_create_nocopy().
From: |
Ben Pfaff |
Subject: |
[PATCH 04/18] output: New function text_item_create_nocopy(). |
Date: |
Sat, 19 Mar 2011 17:09:50 -0700 |
---
src/output/text-item.c | 12 +++++++-----
src/output/text-item.h | 3 ++-
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/output/text-item.c b/src/output/text-item.c
index cb21caa..1531656 100644
--- a/src/output/text-item.c
+++ b/src/output/text-item.c
@@ -1,5 +1,5 @@
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,8 +32,10 @@
#include "gettext.h"
#define _(msgid) gettext (msgid)
-static struct text_item *
-allocate_text_item (enum text_item_type type, char *text)
+/* Creates and returns a new text item containing TEXT and the specified TYPE.
+ The new text item takes ownership of TEXT. */
+struct text_item *
+text_item_create_nocopy (enum text_item_type type, char *text)
{
struct text_item *item = xmalloc (sizeof *item);
output_item_init (&item->output_item, &text_item_class);
@@ -47,7 +49,7 @@ allocate_text_item (enum text_item_type type, char *text)
struct text_item *
text_item_create (enum text_item_type type, const char *text)
{
- return allocate_text_item (type, xstrdup (text));
+ return text_item_create_nocopy (type, xstrdup (text));
}
/* Creates and returns a new text item containing a copy of FORMAT, which is
@@ -60,7 +62,7 @@ text_item_create_format (enum text_item_type type, const char
*format, ...)
va_list args;
va_start (args, format);
- item = allocate_text_item (type, xvasprintf (format, args));
+ item = text_item_create_nocopy (type, xvasprintf (format, args));
va_end (args);
return item;
diff --git a/src/output/text-item.h b/src/output/text-item.h
index 5f1e8a2..da1b208 100644
--- a/src/output/text-item.h
+++ b/src/output/text-item.h
@@ -1,5 +1,5 @@
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009, 2011 Free Sonftware Foundation, Inc.
+ Copyright (C) 2009, 2010, 2011 Free Sonftware Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -67,6 +67,7 @@ struct text_item
};
struct text_item *text_item_create (enum text_item_type, const char *text);
+struct text_item *text_item_create_nocopy (enum text_item_type, char *text);
struct text_item *text_item_create_format (enum text_item_type,
const char *format, ...)
PRINTF_FORMAT (2, 3);
--
1.7.2.3
- [PATCH 00/18] rewrite PSPP lexer, Ben Pfaff, 2011/03/19
- [PATCH 01/18] data-reader: Remove unreachable "return" statements., Ben Pfaff, 2011/03/19
- [PATCH 07/18] str: New functions for checking for and removing string suffixes., Ben Pfaff, 2011/03/19
- [PATCH 10/18] i18n: New function recode_string_len()., Ben Pfaff, 2011/03/19
- [PATCH 09/18] i18n: New function uc_name()., Ben Pfaff, 2011/03/19
- [PATCH 14/18] encoding-guesser: New library to guess the encoding of a text file., Ben Pfaff, 2011/03/19
- [PATCH 04/18] output: New function text_item_create_nocopy().,
Ben Pfaff <=
- [PATCH 05/18] str: New function ss_realloc()., Ben Pfaff, 2011/03/19
- [PATCH 13/18] i18n: New functions and data structure for obtaining encoding info., Ben Pfaff, 2011/03/19
- [PATCH 06/18] str: Rename ss_chomp() to ss_chomp_byte(), ds_chomp() to ds_chomp_byte()., Ben Pfaff, 2011/03/19
- [PATCH 02/18] file-name: Do not make output files line-buffered in fn_open()., Ben Pfaff, 2011/03/19
- [PATCH 12/18] identifier: Rename token_type_to_string() and make a new version., Ben Pfaff, 2011/03/19
- [PATCH 08/18] hash-functions: New function hash_case_bytes()., Ben Pfaff, 2011/03/19
- [PATCH 11/18] i18n: New functions for truncating strings in an arbitrary encoding., Ben Pfaff, 2011/03/19
- [PATCH 17/18] scan: New library for high-level PSPP syntax lexical analysis., Ben Pfaff, 2011/03/19
- [PATCH 15/18] u8-istream: New library for reading a text file and recoding to UTF-8., Ben Pfaff, 2011/03/19
- [PATCH 16/18] segment: New library for low-level phase of lexical syntax analysis., Ben Pfaff, 2011/03/19