gallium: add pipe_context::set_log_context
[mesa.git] / src / util / ralloc.c
index 953f36e6bcd97fa170fbbea9685ddc0af673d617..bf46439df4ea5fe9268ecd8d7ef397ed55f8a5d8 100644 (file)
 #include <string.h>
 #include <stdint.h>
 
-/* Android defines SIZE_MAX in limits.h, instead of the standard stdint.h */
-#ifdef ANDROID
-#include <limits.h>
-#endif
-
 /* Some versions of MinGW are missing _vscprintf's declaration, although they
  * still provide the symbol in the import library. */
 #ifdef __MINGW32__
@@ -408,6 +403,25 @@ ralloc_strncat(char **dest, const char *str, size_t n)
    return cat(dest, str, strnlen(str, n));
 }
 
+bool
+ralloc_str_append(char **dest, const char *str,
+                  size_t existing_length, size_t str_size)
+{
+   char *both;
+   assert(dest != NULL && *dest != NULL);
+
+   both = resize(*dest, existing_length + str_size + 1);
+   if (unlikely(both == NULL))
+      return false;
+
+   memcpy(both + existing_length, str, str_size);
+   both[existing_length + str_size] = '\0';
+
+   *dest = both;
+
+   return true;
+}
+
 char *
 ralloc_asprintf(const void *ctx, const char *fmt, ...)
 {