#include <stdlib.h>
#include <stdio.h>
+#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <memory.h>
{
return strdup_n(string, len);
}
+char* allocprintf(const char*format, ...)
+{
+ va_list arglist1;
+ va_start(arglist1, format);
+ char dummy;
+ int l = vsnprintf(&dummy, 1, format, arglist1);
+ va_end(arglist1);
+
+ va_list arglist2;
+ va_start(arglist2, format);
+ char*buf = malloc(l+1);
+ vsnprintf(buf, l+1, format, arglist2);
+ va_end(arglist2);
+ return buf;
+}
// ------------------------------- mem_t --------------------------------------
void* heap_chopmax(heap_t*h)
{
void*p = h->elements[0];
+ assert(h->size);
h->elements[0] = h->elements[--h->size];
down(h,0);
return p;
void dict_destroy(dict_t*dict)
{
+ if(!dict)
+ return;
dict_clear(dict);
rfx_free(dict);
}