+/*
+ * Return malloced string the contents of which are a concatenation of the
+ * directory name of the first argument and the second argument.
+ */
+static char* get_tmp_file_name(const char* base, const char *tmp_name)
+{
+ char *file_name, *p;
+ /* for sure a few bytes longer than needed */
+ int file_name_size = strlen(base) + sizeof(file_name) + 10;
+
+ file_name = malloc(file_name_size);
+ if (!file_name) {
+ fprintf(stderr, "%s:%d: failed to allocate %d bytes\n",
+ __FILE__, __LINE__, file_name_size);
+ return 0;
+ }
+
+ strcpy(file_name, base);
+ p = strrchr(file_name, '/');
+ if (p)
+ strcpy(p + 1, tmp_name);
+ else
+ strcpy(file_name, tmp_name);
+
+ return file_name;
+}
+