forked from CoolerVoid/0d1n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mem_ops.h
34 lines (29 loc) · 879 Bytes
/
mem_ops.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <curl/curl.h>
// set DEBUG ON
#define BUGVIEW 1
#define DEBUG(x, s...) do { \
if (!BUGVIEW) { break; } \
time_t t = time(NULL); \
char *d = ctime(&t); \
fprintf(stderr, "\n--- DEBUG-START ---\n\n %.*s %s[%d] %s(): \n", \
(int)strlen(d) - 1, d, __FILE__, \
__LINE__, __FUNCTION__); \
fprintf(stderr, x, ## s); \
fprintf(stderr,"\n\n--- DEBUG-END ---\n"); \
} while (0);
struct MemoryStruct {
char *memory;
size_t size;
};
typedef struct MemoryStruct MemoryStruct;
void *xmalloc (size_t size);
void *xcalloc (size_t mem, size_t size);
void *xrealloc (void *ptr, size_t size);
void xfree(void **ptr);
size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms);