aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-29 11:27:14 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-29 16:14:51 -0800
commit8ada404c5f1ec068a8bad144b63878d9962aa1f0 (patch)
tree6964537047cec6e4b09d0744a01c3208b26dbfea /common.h
parentebba30d67157cf0dee46edfa5f47a216b1f35ae6 (diff)
More work towards improving relationship between multithreading and fork
Diffstat (limited to 'common.h')
-rw-r--r--common.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/common.h b/common.h
index b1186df6..62fa7378 100644
--- a/common.h
+++ b/common.h
@@ -338,6 +338,7 @@ class null_terminated_array_t {
public:
null_terminated_array_t() : array(NULL) { }
+ null_terminated_array_t(const string_list_t &argv) : array(NULL) { this->set(argv); }
~null_terminated_array_t() { this->free(); }
/** operator=. Notice the pass-by-value parameter. */
@@ -348,7 +349,7 @@ class null_terminated_array_t {
}
/* Copy constructor. */
- null_terminated_array_t(const null_terminated_array_t &him) {
+ null_terminated_array_t(const null_terminated_array_t &him) : array(NULL) {
this->set(him.array);
}
@@ -401,9 +402,11 @@ class null_terminated_array_t {
}
return lst;
}
-
};
+/* Helper function to convert from a null_terminated_array_t<wchar_t> to a null_terminated_array_t<char_t> */
+null_terminated_array_t<char> convert_wide_array_to_narrow(const null_terminated_array_t<wchar_t> &arr);
+
bool is_forked_child();
/* Basic scoped lock class */
@@ -666,12 +669,20 @@ int create_directory( const wcstring &d );
*/
void bugreport();
-/**
- Format the specified size (in bytes, kilobytes, etc.) into the specified stringbuffer.
-*/
+/** Format the specified size (in bytes, kilobytes, etc.) into the specified stringbuffer. */
void sb_format_size( string_buffer_t *sb, long long sz );
wcstring format_size(long long sz);
+/** Version of format_size that does not allocate memory. */
+void format_size_safe(char buff[128], unsigned long long sz);
+
+/** Our crappier versions of debug which is guaranteed to not allocate any memory, or do anything other than call write(). This is useful after a call to fork() with threads. */
+void debug_safe(int level, const char *msg, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL);
+
+/** Writes out an int safely */
+void format_int_safe(char buff[128], int val);
+
+
/**
Return the number of seconds from the UNIX epoch, with subsecond
precision. This function uses the gettimeofday function, and will