]>
jfr.im git - irc/quakenet/newserv.git/blob - lib/sstring-valgrind.c
1 #define COMPILING_SSTRING
4 #include "../core/hooks.h"
5 #include "../core/nsmalloc.h"
6 #include "../core/error.h"
15 typedef struct sstringlist
{
16 struct sstringlist
*prev
;
17 struct sstringlist
*next
;
21 static sstringlist
*head
;
29 /* here we deliberately don't free the pointers so valgrind can tell us where they were allocated, in theory */
36 Error("sstring", ERR_WARNING
, "sstring of length %d still allocated: %s", s
->s
->u
.l
.length
, s
->s
->content
);
42 sstring
*getsstring(const char *inputstr
, int maxlen
) {
50 for(p
=(char *)inputstr
;*p
&&maxlen
;maxlen
--,p
++)
54 s
=(sstringlist
*)malloc(sizeof(sstringlist
) + sizeof(sstring
));
56 s
->s
->u
.l
.length
= len
;
57 s
->s
->content
=(char *)malloc(len
+ 1);
59 memcpy(s
->s
->content
, inputstr
, len
);
60 s
->s
->content
[len
] = '\0';
71 void freesstring(sstring
*inval
) {
76 s
= (sstringlist
*)inval
- 1;
79 s
->prev
->next
= s
->next
;
81 s
->next
->prev
= s
->prev
;