Crossfire Server, Branch 1.12  R12190
Data Structures | Functions
stringbuffer.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "global.h"
#include "libproto.h"
#include "stringbuffer.h"
Include dependency graph for stringbuffer.c:

Go to the source code of this file.

Data Structures

struct  StringBuffer

Functions

void stringbuffer_append_printf (StringBuffer *sb, const char *format,...)
 Append a formatted string to a string buffer instance.
void stringbuffer_append_string (StringBuffer *sb, const char *str)
 Append a string to a string buffer instance.
void stringbuffer_append_stringbuffer (StringBuffer *sb, const StringBuffer *sb2)
 Append the contents of a string buffer instance to another string buffer instance.
static void stringbuffer_ensure (StringBuffer *sb, size_t len)
 Make sure that at least len bytes are available in the passed string buffer.
char * stringbuffer_finish (StringBuffer *sb)
 Deallocate the string buffer instance and return the string.
sstring stringbuffer_finish_shared (StringBuffer *sb)
 Deallocate the string buffer instance and return the string as a shared string.
StringBufferstringbuffer_new (void)
 Create a new string buffer.

Function Documentation

void stringbuffer_append_printf ( StringBuffer sb,
const char *  format,
  ... 
)

Append a formatted string to a string buffer instance.

Parameters:
sbThe string buffer to modify.
formatThe format string to append.

Definition at line 106 of file stringbuffer.c.

References StringBuffer::buf, StringBuffer::pos, stringbuffer_ensure(), and vsnprintf.

Referenced by cost_string_from_value(), dump_object(), query_cost_string(), and real_money_value().

Here is the call graph for this function:

Here is the caller graph for this function:

void stringbuffer_append_string ( StringBuffer sb,
const char *  str 
)

Append a string to a string buffer instance.

Parameters:
sbThe string buffer to modify.
strThe string to append.

Definition at line 97 of file stringbuffer.c.

References StringBuffer::buf, StringBuffer::pos, and stringbuffer_ensure().

Referenced by cost_string_from_value(), dump_object(), and query_cost_string().

Here is the call graph for this function:

Here is the caller graph for this function:

Append the contents of a string buffer instance to another string buffer instance.

Parameters:
sbThe string buffer to modify.
sb2The string buffer to append; it must be different from sb.

Definition at line 133 of file stringbuffer.c.

References StringBuffer::buf, StringBuffer::pos, and stringbuffer_ensure().

Here is the call graph for this function:

static void stringbuffer_ensure ( StringBuffer sb,
size_t  len 
) [static]

Make sure that at least len bytes are available in the passed string buffer.

Parameters:
sbThe string buffer to modify.
lenThe number of bytes to allocate.

Definition at line 139 of file stringbuffer.c.

References StringBuffer::buf, fatal(), OUT_OF_MEMORY, StringBuffer::pos, and StringBuffer::size.

Referenced by stringbuffer_append_printf(), stringbuffer_append_string(), and stringbuffer_append_stringbuffer().

Here is the call graph for this function:

Here is the caller graph for this function:

Deallocate the string buffer instance and return the string.

The passed string buffer must not be accessed afterwards.

Parameters:
sbThe string buffer to deallocate.
Returns:
The result string; to free it, call free() on it.

Definition at line 78 of file stringbuffer.c.

References StringBuffer::buf, and StringBuffer::pos.

Referenced by add_one_item(), animate_object(), can_pay(), command_diff(), command_dump(), command_dumpbelow(), describe_shop(), dump_all_archetypes(), dump_all_objects(), examine(), free_object2(), gate_type_process(), get_payment(), insert_ob_in_map(), insert_ob_in_ob(), pick_up_object(), process_events(), remove_ob(), sell_item(), SockList_AddStringBuffer(), START_TEST(), and stringbuffer_finish_shared().

Here is the caller graph for this function:

Deallocate the string buffer instance and return the string as a shared string.

The passed string buffer must not be accessed afterwards.

Parameters:
sbThe string buffer to deallocate.
Returns:
The result shared string; to free it, call free_string() on it.

Definition at line 87 of file stringbuffer.c.

References add_string(), and stringbuffer_finish().

Here is the call graph for this function:

Create a new string buffer.

Returns:
The newly allocated string buffer.

Definition at line 64 of file stringbuffer.c.

References StringBuffer::buf, fatal(), OUT_OF_MEMORY, StringBuffer::pos, and StringBuffer::size.

Referenced by add_one_item(), animate_object(), command_diff(), command_dump(), command_dumpbelow(), cost_string_from_value(), dump_all_archetypes(), dump_all_objects(), free_object2(), gate_type_process(), insert_ob_in_map(), insert_ob_in_ob(), process_events(), query_cost_string(), remove_ob(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function: