-#include "imio.h"
+#include "imager.h"
+#include "imageri.h"
#include <stdlib.h>
#ifndef _MSC_VER
#include <unistd.h>
return buf;
}
-
-
-
void
malloc_state(void) {
int i, total = 0;
return buf;
}
+void *
+(mymalloc)(int size) {
+ return mymalloc_file_line(size, "unknown", 0);
+}
+
void*
myrealloc_file_line(void *ptr, size_t newsize, char* file, int line) {
char *buf;
return buf;
}
+void *
+(myrealloc)(void *ptr, size_t newsize) {
+ return myrealloc_file_line(ptr, newsize, "unknown", 0);
+}
+
static
void
bndcheck(int idx) {
bndcheck(idx);
}
-
-
-
-
void
myfree_file_line(void *p, char *file, int line) {
char *pp = p;
int match = 0;
int i;
+
+ if (p == NULL)
+ return;
for(i=0; i<MAXMAL; i++) if (malloc_pointers[i].ptr == p) {
mm_log((1,"myfree_file_line: pointer %i (%s) freed at %s (%i)\n", i, malloc_pointers[i].comm, file, line));
free(pp-UNDRRNVAL);
}
+void
+(myfree)(void *block) {
+ myfree_file_line(block, "unknown", 0);
+}
+
#else
#define malloc_comm(a,b) (mymalloc(a))
void
malloc_state() {
- printf("malloc_state: not in debug mode\n");
}
void*
return buf;
}
+void *
+mymalloc_file_line(size_t size, char *file, int line) {
+ return mymalloc(size);
+}
+
void
myfree(void *p) {
mm_log((1, "myfree(p %p)\n", p));
free(p);
}
+void
+myfree_file_line(void *p, char *file, int line) {
+ myfree(p);
+}
+
void *
myrealloc(void *block, size_t size) {
void *result;
return result;
}
+void *
+myrealloc_file_line(void *block, size_t newsize, char *file, int size) {
+ return myrealloc(block, newsize);
+}
+
#endif /* IMAGER_MALLOC_DEBUG */
#undef min
#undef max
-int
-i_min(int a,int b) {
+i_img_dim
+i_minx(i_img_dim a, i_img_dim b) {
if (a<b) return a; else return b;
}
-int
-i_max(int a,int b) {
+i_img_dim
+i_maxx(i_img_dim a, i_img_dim b) {
if (a>b) return a; else return b;
}
};
/*
-=item utf8_advance(char **p, int *len)
+=item i_utf8_advance(char **p, size_t *len)
-Retreive a UTF8 character from the stream.
+Retrieve a C<UTF-8> character from the stream.
Modifies *p and *len to indicate the consumed characters.
-This doesn't support the extended UTF8 encoding used by later versions
-of Perl.
+This doesn't support the extended C<UTF-8> encoding used by later
+versions of Perl.
+
+This doesn't check that the C<UTF-8> character is using the shortest
+possible representation.
=cut
*/
-unsigned long i_utf8_advance(char const **p, int *len) {
+unsigned long
+i_utf8_advance(char const **p, size_t *len) {
unsigned char c;
int i, ci, clen = 0;
unsigned char codes[3];
for (i = 0; i < sizeof(utf8_sizes)/sizeof(*utf8_sizes); ++i) {
if ((c & utf8_sizes[i].mask) == utf8_sizes[i].expect) {
clen = utf8_sizes[i].size;
+ break;
}
}
if (clen == 0 || *len < clen-1) {