1 |
|
/* |
2 |
< |
* i-scream central monitoring system |
2 |
> |
* i-scream libstatgrab |
3 |
|
* http://www.i-scream.org |
4 |
|
* Copyright (C) 2000-2004 i-scream |
5 |
|
* |
30 |
|
#include <stdlib.h> |
31 |
|
#include <unistd.h> |
32 |
|
#include <sys/types.h> |
33 |
– |
#include <regex.h> |
33 |
|
#ifdef ALLBSD |
34 |
|
#include <fcntl.h> |
35 |
|
#endif |
36 |
|
#if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD) |
37 |
|
#include <kvm.h> |
38 |
+ |
#include <paths.h> |
39 |
|
#endif |
40 |
|
#if defined(NETBSD) || defined(OPENBSD) |
41 |
|
#include <uvm/uvm_extern.h> |
42 |
|
#include <sys/param.h> |
43 |
|
#include <sys/sysctl.h> |
44 |
|
#endif |
45 |
+ |
#ifdef HPUX |
46 |
+ |
#include <sys/param.h> |
47 |
+ |
#include <sys/pstat.h> |
48 |
+ |
#endif |
49 |
|
|
50 |
|
#include "tools.h" |
51 |
+ |
#include "statgrab.h" |
52 |
|
|
53 |
|
#ifdef SOLARIS |
54 |
|
#ifdef HAVE_LIBDEVINFO_H |
64 |
|
#include <sys/fcntl.h> |
65 |
|
#include <dirent.h> |
66 |
|
#endif |
67 |
+ |
#ifdef WIN32 |
68 |
+ |
#include "win32.h" |
69 |
+ |
#endif |
70 |
|
|
71 |
|
#if defined(SOLARIS) && defined(HAVE_LIBDEVINFO_H) |
72 |
|
struct map{ |
81 |
|
#endif |
82 |
|
|
83 |
|
#ifdef SOLARIS |
84 |
< |
char *get_svr_from_bsd(char *bsd){ |
84 |
> |
const char *sg_get_svr_from_bsd(const char *bsd){ |
85 |
|
#ifdef HAVE_LIBDEVINFO_H |
86 |
|
mapping_t *map_ptr; |
87 |
|
for(map_ptr = mapping; map_ptr != NULL; map_ptr = map_ptr->next) |
92 |
|
#endif |
93 |
|
|
94 |
|
#if defined(SOLARIS) && defined(HAVE_LIBDEVINFO_H) |
95 |
< |
void add_mapping(char *bsd, char *svr){ |
95 |
> |
static void add_mapping(char *bsd, char *svr){ |
96 |
|
mapping_t *map_ptr; |
97 |
|
mapping_t *map_end_ptr; |
98 |
|
|
91 |
– |
bsd = strdup(bsd); |
92 |
– |
svr = strdup(svr); |
93 |
– |
|
99 |
|
if (mapping == NULL){ |
100 |
< |
mapping = malloc(sizeof(mapping_t)); |
100 |
> |
mapping = sg_malloc(sizeof(mapping_t)); |
101 |
|
if (mapping == NULL) return; |
102 |
|
map_ptr = mapping; |
103 |
|
}else{ |
112 |
|
/* We've reached end of list and not found the entry.. So we need to malloc |
113 |
|
* new mapping_t |
114 |
|
*/ |
115 |
< |
map_end_ptr->next = malloc(sizeof(mapping_t)); |
115 |
> |
map_end_ptr->next = sg_malloc(sizeof(mapping_t)); |
116 |
|
if (map_end_ptr->next == NULL) return; |
117 |
|
map_ptr = map_end_ptr->next; |
118 |
|
} |
119 |
|
|
120 |
|
map_ptr->next = NULL; |
121 |
< |
map_ptr->bsd = bsd; |
122 |
< |
map_ptr->svr = svr; |
121 |
> |
map_ptr->bsd = NULL; |
122 |
> |
map_ptr->svr = NULL; |
123 |
> |
if (sg_update_string(&map_ptr->bsd, bsd) < 0 |
124 |
> |
|| sg_update_string(&map_ptr->svr, svr) < 0) { |
125 |
> |
return; |
126 |
> |
} |
127 |
|
|
128 |
|
return; |
129 |
|
} |
130 |
|
|
131 |
< |
char *read_dir(char *disk_path){ |
131 |
> |
|
132 |
> |
static char *read_dir(char *disk_path){ |
133 |
|
DIR *dirp; |
134 |
|
struct dirent *dp; |
135 |
|
struct stat stbuf; |
136 |
< |
char *svr_name; |
136 |
> |
char *svr_name = NULL; |
137 |
|
char current_dir[MAXPATHLEN]; |
138 |
|
char file_name[MAXPATHLEN]; |
139 |
|
char temp_name[MAXPATHLEN]; |
160 |
|
x = readlink(dir_dname, file_name, sizeof(file_name)); |
161 |
|
file_name[x] = '\0'; |
162 |
|
if (strcmp(file_name, temp_name) == 0) { |
163 |
< |
svr_name = strdup(dp->d_name); |
163 |
> |
if (sg_update_string(&svr_name, |
164 |
> |
dp->d_name) < 0) { |
165 |
> |
return NULL; |
166 |
> |
} |
167 |
|
closedir(dirp); |
168 |
|
return svr_name; |
169 |
|
} |
174 |
|
} |
175 |
|
|
176 |
|
|
177 |
< |
|
165 |
< |
int get_alias(char *alias){ |
177 |
> |
static int get_alias(char *alias){ |
178 |
|
char file[MAXPATHLEN]; |
179 |
|
di_node_t root_node; |
180 |
|
di_node_t node; |
185 |
|
char *value; |
186 |
|
int instance; |
187 |
|
if ((root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { |
188 |
< |
return 1; |
188 |
> |
return -1; |
189 |
|
} |
190 |
|
node = di_drv_first_node(alias, root_node); |
191 |
|
while (node != DI_NODE_NIL) { |
195 |
|
minor_name = di_minor_name(minor); |
196 |
|
strcpy(tmpnode, alias); |
197 |
|
sprintf(tmpnode, "%s%d", tmpnode, instance); |
198 |
< |
strlcpy(file, "/devices", sizeof file); |
199 |
< |
strlcat(file, phys_path, sizeof file); |
200 |
< |
strlcat(file, ":", sizeof file); |
201 |
< |
strlcat(file, minor_name, sizeof file); |
198 |
> |
sg_strlcpy(file, "/devices", sizeof file); |
199 |
> |
sg_strlcat(file, phys_path, sizeof file); |
200 |
> |
sg_strlcat(file, ":", sizeof file); |
201 |
> |
sg_strlcat(file, minor_name, sizeof file); |
202 |
|
value = read_dir(file); |
203 |
|
if (value != NULL){ |
204 |
|
add_mapping(tmpnode, value); |
215 |
|
|
216 |
|
|
217 |
|
#define BIG_ENOUGH 512 |
218 |
< |
int build_mapping(){ |
218 |
> |
static int build_mapping(){ |
219 |
|
char device_name[BIG_ENOUGH]; |
220 |
|
int x; |
221 |
|
kstat_ctl_t *kc; |
227 |
|
int found; |
228 |
|
|
229 |
|
if ((kc = kstat_open()) == NULL) { |
230 |
< |
return; |
230 |
> |
return -1; |
231 |
|
} |
232 |
|
|
233 |
|
for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) { |
237 |
|
if(strcmp(ksp->ks_module, "md")==0) continue; |
238 |
|
if((kstat_read(kc, ksp, &kios))==-1) continue; |
239 |
|
strncpy(device_name, ksp->ks_name, sizeof device_name); |
240 |
< |
for(x=0;x<(sizeof device_name);x++){ |
240 |
> |
for(x=0;x<(int)(sizeof device_name);x++){ |
241 |
|
if( isdigit((int)device_name[x]) ) break; |
242 |
|
} |
243 |
|
if(x == sizeof device_name) x--; |
249 |
|
if (x>=BIG_ENOUGH){ |
250 |
|
/* We've got bigger than we thought was massive */ |
251 |
|
/* If we hit this.. Make big enough bigger */ |
252 |
< |
return 1; |
252 |
> |
return -1; |
253 |
|
} |
254 |
|
if( !strncmp(driver_list[x], device_name, BIG_ENOUGH)){ |
255 |
|
found = 1; |
259 |
|
|
260 |
|
if(!found){ |
261 |
|
if((get_alias(device_name)) != 0){ |
262 |
< |
return 1; |
262 |
> |
return -1; |
263 |
|
} |
264 |
|
strncpy(driver_list[x], device_name, BIG_ENOUGH); |
265 |
|
list_entries++; |
272 |
|
|
273 |
|
#endif |
274 |
|
|
275 |
< |
|
276 |
< |
|
265 |
< |
char *f_read_line(FILE *f, const char *string){ |
275 |
> |
#if defined(LINUX) || defined(CYGWIN) |
276 |
> |
char *sg_f_read_line(FILE *f, const char *string){ |
277 |
|
/* Max line length. 8k should be more than enough */ |
278 |
|
static char line[8192]; |
279 |
|
|
283 |
|
} |
284 |
|
} |
285 |
|
|
286 |
+ |
sg_set_error(SG_ERROR_PARSE, NULL); |
287 |
|
return NULL; |
288 |
|
} |
289 |
|
|
290 |
< |
char *get_string_match(char *line, regmatch_t *match){ |
290 |
> |
char *sg_get_string_match(char *line, regmatch_t *match){ |
291 |
|
int len=match->rm_eo - match->rm_so; |
292 |
< |
char *match_string=malloc(len+1); |
292 |
> |
char *match_string=sg_malloc(len+1); |
293 |
|
|
294 |
|
match_string=strncpy(match_string, line+match->rm_so, len); |
295 |
|
match_string[len]='\0'; |
297 |
|
return match_string; |
298 |
|
} |
299 |
|
|
300 |
< |
|
289 |
< |
|
300 |
> |
/* Cygwin (without a recent newlib) doesn't have atoll */ |
301 |
|
#ifndef HAVE_ATOLL |
302 |
|
static long long atoll(const char *s) { |
303 |
|
long long value = 0; |
318 |
|
} |
319 |
|
#endif |
320 |
|
|
321 |
< |
#ifndef HAVE_STRLCPY |
321 |
> |
long long sg_get_ll_match(char *line, regmatch_t *match){ |
322 |
> |
char *ptr; |
323 |
> |
long long num; |
324 |
> |
|
325 |
> |
ptr=line+match->rm_so; |
326 |
> |
num=atoll(ptr); |
327 |
> |
|
328 |
> |
return num; |
329 |
> |
} |
330 |
> |
#endif |
331 |
> |
|
332 |
|
/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ |
333 |
|
|
334 |
|
/* |
352 |
|
* will be copied. Always NUL terminates (unless siz == 0). |
353 |
|
* Returns strlen(src); if retval >= siz, truncation occurred. |
354 |
|
*/ |
355 |
< |
size_t strlcpy(char *dst, const char *src, size_t siz){ |
356 |
< |
register char *d = dst; |
357 |
< |
register const char *s = src; |
358 |
< |
register size_t n = siz; |
355 |
> |
size_t sg_strlcpy(char *dst, const char *src, size_t siz){ |
356 |
> |
register char *d = dst; |
357 |
> |
register const char *s = src; |
358 |
> |
register size_t n = siz; |
359 |
|
|
360 |
< |
/* Copy as many bytes as will fit */ |
361 |
< |
if (n != 0 && --n != 0) { |
362 |
< |
do { |
363 |
< |
if ((*d++ = *s++) == 0) |
364 |
< |
break; |
365 |
< |
} while (--n != 0); |
366 |
< |
} |
360 |
> |
/* Copy as many bytes as will fit */ |
361 |
> |
if (n != 0 && --n != 0) { |
362 |
> |
do { |
363 |
> |
if ((*d++ = *s++) == 0) |
364 |
> |
break; |
365 |
> |
} while (--n != 0); |
366 |
> |
} |
367 |
|
|
368 |
< |
/* Not enough room in dst, add NUL and traverse rest of src */ |
369 |
< |
if (n == 0) { |
370 |
< |
if (siz != 0) |
371 |
< |
*d = '\0'; /* NUL-terminate dst */ |
372 |
< |
while (*s++) |
373 |
< |
; |
374 |
< |
} |
368 |
> |
/* Not enough room in dst, add NUL and traverse rest of src */ |
369 |
> |
if (n == 0) { |
370 |
> |
if (siz != 0) |
371 |
> |
*d = '\0'; /* NUL-terminate dst */ |
372 |
> |
while (*s++) |
373 |
> |
; |
374 |
> |
} |
375 |
|
|
376 |
< |
return(s - src - 1); /* count does not include NUL */ |
376 |
> |
return(s - src - 1); /* count does not include NUL */ |
377 |
|
} |
357 |
– |
#endif |
378 |
|
|
359 |
– |
#ifndef HAVE_STRLCAT |
379 |
|
/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */ |
380 |
|
|
381 |
|
/* |
401 |
|
* Returns strlen(src) + MIN(siz, strlen(initial dst)). |
402 |
|
* If retval >= siz, truncation occurred. |
403 |
|
*/ |
404 |
< |
size_t strlcat(char *dst, const char *src, size_t siz){ |
405 |
< |
register char *d = dst; |
406 |
< |
register const char *s = src; |
407 |
< |
register size_t n = siz; |
408 |
< |
size_t dlen; |
404 |
> |
size_t sg_strlcat(char *dst, const char *src, size_t siz){ |
405 |
> |
register char *d = dst; |
406 |
> |
register const char *s = src; |
407 |
> |
register size_t n = siz; |
408 |
> |
size_t dlen; |
409 |
|
|
410 |
< |
/* Find the end of dst and adjust bytes left but don't go past end */ |
411 |
< |
while (n-- != 0 && *d != '\0') |
412 |
< |
d++; |
413 |
< |
dlen = d - dst; |
414 |
< |
n = siz - dlen; |
410 |
> |
/* Find the end of dst and adjust bytes left but don't go past end */ |
411 |
> |
while (n-- != 0 && *d != '\0') |
412 |
> |
d++; |
413 |
> |
dlen = d - dst; |
414 |
> |
n = siz - dlen; |
415 |
|
|
416 |
< |
if (n == 0) |
417 |
< |
return(dlen + strlen(s)); |
418 |
< |
while (*s != '\0') { |
419 |
< |
if (n != 1) { |
420 |
< |
*d++ = *s; |
421 |
< |
n--; |
422 |
< |
} |
423 |
< |
s++; |
424 |
< |
} |
425 |
< |
*d = '\0'; |
416 |
> |
if (n == 0) |
417 |
> |
return(dlen + strlen(s)); |
418 |
> |
while (*s != '\0') { |
419 |
> |
if (n != 1) { |
420 |
> |
*d++ = *s; |
421 |
> |
n--; |
422 |
> |
} |
423 |
> |
s++; |
424 |
> |
} |
425 |
> |
*d = '\0'; |
426 |
|
|
427 |
< |
return(dlen + (s - src)); /* count does not include NUL */ |
427 |
> |
return(dlen + (s - src)); /* count does not include NUL */ |
428 |
|
} |
429 |
|
|
430 |
< |
#endif |
430 |
> |
int sg_update_string(char **dest, const char *src) { |
431 |
> |
char *new; |
432 |
|
|
433 |
< |
long long get_ll_match(char *line, regmatch_t *match){ |
434 |
< |
char *ptr; |
435 |
< |
long long num; |
433 |
> |
if (src == NULL) { |
434 |
> |
/* We're being told to set it to NULL. */ |
435 |
> |
free(*dest); |
436 |
> |
*dest = NULL; |
437 |
> |
return 0; |
438 |
> |
} |
439 |
|
|
440 |
< |
ptr=line+match->rm_so; |
441 |
< |
num=atoll(ptr); |
440 |
> |
new = sg_realloc(*dest, strlen(src) + 1); |
441 |
> |
if (new == NULL) { |
442 |
> |
return -1; |
443 |
> |
} |
444 |
|
|
445 |
< |
return num; |
445 |
> |
strcpy(new, src); |
446 |
> |
*dest = new; |
447 |
> |
return 0; |
448 |
|
} |
449 |
|
|
450 |
+ |
/* join two strings together */ |
451 |
+ |
int sg_concat_string(char **dest, const char *src) { |
452 |
+ |
char *new; |
453 |
+ |
int len = strlen(*dest) + strlen(src) + 1; |
454 |
+ |
|
455 |
+ |
new = sg_realloc(*dest, len); |
456 |
+ |
if (new == NULL) { |
457 |
+ |
return -1; |
458 |
+ |
} |
459 |
+ |
|
460 |
+ |
*dest = new; |
461 |
+ |
strcat(*dest, src); |
462 |
+ |
return 0; |
463 |
+ |
} |
464 |
+ |
|
465 |
|
#if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD) |
466 |
< |
kvm_t *get_kvm() { |
466 |
> |
kvm_t *sg_get_kvm() { |
467 |
|
static kvm_t *kvmd = NULL; |
468 |
|
|
469 |
|
if (kvmd != NULL) { |
471 |
|
} |
472 |
|
|
473 |
|
kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, NULL); |
474 |
+ |
if(kvmd == NULL) { |
475 |
+ |
sg_set_error(SG_ERROR_KVM_OPENFILES, NULL); |
476 |
+ |
} |
477 |
|
return kvmd; |
478 |
|
} |
479 |
|
|
480 |
|
/* Can't think of a better name for this function */ |
481 |
< |
kvm_t *get_kvm2() { |
481 |
> |
kvm_t *sg_get_kvm2() { |
482 |
|
static kvm_t *kvmd2 = NULL; |
483 |
|
|
484 |
|
if (kvmd2 != NULL) { |
486 |
|
} |
487 |
|
|
488 |
|
kvmd2 = kvm_openfiles(_PATH_DEVNULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL); |
489 |
+ |
if(kvmd2 == NULL) { |
490 |
+ |
sg_set_error(SG_ERROR_KVM_OPENFILES, NULL); |
491 |
+ |
} |
492 |
|
return kvmd2; |
493 |
|
} |
494 |
|
#endif |
495 |
|
|
496 |
|
#if defined(NETBSD) || defined(OPENBSD) |
497 |
< |
struct uvmexp *get_uvmexp() { |
497 |
> |
struct uvmexp *sg_get_uvmexp() { |
498 |
|
int mib[2]; |
499 |
< |
size_t size; |
500 |
< |
static struct uvmexp *uvm = NULL; |
499 |
> |
size_t size = sizeof(struct uvmexp); |
500 |
> |
static struct uvmexp uvm; |
501 |
> |
struct uvmexp *new; |
502 |
|
|
503 |
|
mib[0] = CTL_VM; |
504 |
|
mib[1] = VM_UVMEXP; |
505 |
|
|
506 |
< |
if (sysctl(mib, 2, NULL, &size, NULL, 0) < 0) { |
506 |
> |
if (sysctl(mib, 2, &uvm, &size, NULL, 0) < 0) { |
507 |
> |
sg_set_error_with_errno(SG_ERROR_SYSCTL, "CTL_VM.VM_UVMEXP"); |
508 |
|
return NULL; |
509 |
|
} |
510 |
|
|
511 |
< |
uvm = realloc(uvm, size); |
512 |
< |
if (uvm == NULL) { |
513 |
< |
return NULL; |
464 |
< |
} |
511 |
> |
return &uvm; |
512 |
> |
} |
513 |
> |
#endif |
514 |
|
|
515 |
< |
if (sysctl(mib, 2, uvm, &size, NULL, 0) < 0) { |
516 |
< |
return NULL; |
517 |
< |
} |
515 |
> |
#ifdef HPUX |
516 |
> |
struct pst_static *sg_get_pstat_static() { |
517 |
> |
static int got = 0; |
518 |
> |
static struct pst_static pst; |
519 |
|
|
520 |
< |
return uvm; |
520 |
> |
if (!got) { |
521 |
> |
if (pstat_getstatic(&pst, sizeof pst, 1, 0) == -1) { |
522 |
> |
sg_set_error_with_errno(SG_ERROR_PSTAT, |
523 |
> |
"pstat_static"); |
524 |
> |
return NULL; |
525 |
> |
} |
526 |
> |
got = 1; |
527 |
> |
} |
528 |
> |
return &pst; |
529 |
|
} |
530 |
|
#endif |
531 |
|
|
532 |
< |
int statgrab_init(){ |
532 |
> |
int sg_init(){ |
533 |
> |
sg_set_error(SG_ERROR_NONE, NULL); |
534 |
> |
|
535 |
|
#if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD) |
536 |
< |
{ |
537 |
< |
kvm_t *kvmd = get_kvm(); |
478 |
< |
if (kvmd == NULL) return 1; |
536 |
> |
if (sg_get_kvm() == NULL) { |
537 |
> |
return -1; |
538 |
|
} |
539 |
< |
{ |
540 |
< |
kvm_t *kvmd2 = get_kvm2(); |
482 |
< |
if (kvmd2 == NULL) return 1; |
539 |
> |
if (sg_get_kvm2() == NULL) { |
540 |
> |
return -1; |
541 |
|
} |
542 |
|
#endif |
485 |
– |
#if defined(NETBSD) || defined(OPENBSD) |
486 |
– |
{ |
487 |
– |
/* This should always succeed, but it seems that on some |
488 |
– |
* versions of NetBSD the first call to get_uvmexp will return |
489 |
– |
* a non-filled-in structure; this is a workaround for that. |
490 |
– |
*/ |
491 |
– |
struct uvmexp *uvm = get_uvmexp(); |
492 |
– |
if (uvm == NULL) return 1; |
493 |
– |
} |
494 |
– |
#endif |
543 |
|
#ifdef SOLARIS |
544 |
|
/* On solaris 7, this will fail if you are not root. But, everything |
545 |
|
* will still work, just no disk mappings. So we will ignore the exit |
549 |
|
build_mapping(); |
550 |
|
#endif |
551 |
|
#endif |
552 |
+ |
#ifdef WIN32 |
553 |
+ |
return sg_win32_start_capture(); |
554 |
+ |
#endif |
555 |
|
return 0; |
556 |
|
} |
557 |
|
|
558 |
< |
int statgrab_drop_privileges() { |
559 |
< |
if (setegid(getgid()) != 0) return -1; |
560 |
< |
if (seteuid(getuid()) != 0) return -1; |
558 |
> |
int sg_shutdown() { |
559 |
> |
#ifdef WIN32 |
560 |
> |
sg_win32_end_capture(); |
561 |
> |
#endif |
562 |
|
return 0; |
563 |
|
} |
564 |
|
|
565 |
+ |
int sg_snapshot() { |
566 |
+ |
#ifdef WIN32 |
567 |
+ |
return sg_win32_snapshot(); |
568 |
+ |
#else |
569 |
+ |
return 0; |
570 |
+ |
#endif |
571 |
+ |
} |
572 |
+ |
|
573 |
+ |
int sg_drop_privileges() { |
574 |
+ |
#ifndef WIN32 |
575 |
+ |
#ifdef HAVE_SETEGID |
576 |
+ |
if (setegid(getgid()) != 0) { |
577 |
+ |
#elif defined(HAVE_SETRESGID) |
578 |
+ |
if (setresgid(getgid(), getgid(), getgid()) != 0) { |
579 |
+ |
#else |
580 |
+ |
{ |
581 |
+ |
#endif |
582 |
+ |
sg_set_error_with_errno(SG_ERROR_SETEGID, NULL); |
583 |
+ |
return -1; |
584 |
+ |
} |
585 |
+ |
#ifdef HAVE_SETEUID |
586 |
+ |
if (seteuid(getuid()) != 0) { |
587 |
+ |
#elif defined(HAVE_SETRESUID) |
588 |
+ |
if (setresuid(getuid(), getuid(), getuid()) != 0) { |
589 |
+ |
#else |
590 |
+ |
{ |
591 |
+ |
#endif |
592 |
+ |
sg_set_error_with_errno(SG_ERROR_SETEUID, NULL); |
593 |
+ |
return -1; |
594 |
+ |
} |
595 |
+ |
#endif /* WIN32 */ |
596 |
+ |
return 0; |
597 |
+ |
} |
598 |
+ |
|
599 |
+ |
void *sg_realloc(void *ptr, size_t size) { |
600 |
+ |
void *tmp = NULL; |
601 |
+ |
tmp = realloc(ptr, size); |
602 |
+ |
if(tmp == NULL) { |
603 |
+ |
sg_set_error_with_errno(SG_ERROR_MALLOC, NULL); |
604 |
+ |
} |
605 |
+ |
return tmp; |
606 |
+ |
} |