summaryrefslogtreecommitdiffstats
path: root/src/uv-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/uv-common.c')
-rw-r--r--src/uv-common.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/uv-common.c b/src/uv-common.c
index 066eb31..5cb1a8c 100644
--- a/src/uv-common.c
+++ b/src/uv-common.c
@@ -100,6 +100,17 @@ void* uv__realloc(void* ptr, size_t size) {
return NULL;
}
+void* uv__reallocf(void* ptr, size_t size) {
+ void* newptr;
+
+ newptr = uv__realloc(ptr, size);
+ if (newptr == NULL)
+ if (size > 0)
+ uv__free(ptr);
+
+ return newptr;
+}
+
int uv_replace_allocator(uv_malloc_func malloc_func,
uv_realloc_func realloc_func,
uv_calloc_func calloc_func,
@@ -211,6 +222,9 @@ int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr) {
memset(addr, 0, sizeof(*addr));
addr->sin_family = AF_INET;
addr->sin_port = htons(port);
+#ifdef SIN6_LEN
+ addr->sin_len = sizeof(*addr);
+#endif
return uv_inet_pton(AF_INET, ip, &(addr->sin_addr.s_addr));
}
@@ -786,3 +800,24 @@ void uv_loop_delete(uv_loop_t* loop) {
if (loop != default_loop)
uv__free(loop);
}
+
+
+void uv_os_free_environ(uv_env_item_t* envitems, int count) {
+ int i;
+
+ for (i = 0; i < count; i++) {
+ uv__free(envitems[i].name);
+ }
+
+ uv__free(envitems);
+}
+
+
+void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ uv__free(cpu_infos[i].model);
+
+ uv__free(cpu_infos);
+}