X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/718b8c972da5014386e04ce9663464b9f44391dc..e1c0692925:/io.c diff --git a/io.c b/io.c index 4576bf9e..222553ab 100644 --- a/io.c +++ b/io.c @@ -1,4 +1,5 @@ #include "imager.h" +#include "imageri.h" #include #ifndef _MSC_VER #include @@ -24,7 +25,8 @@ static int malloc_need_init = 1; typedef struct { void* ptr; size_t size; - char comm[MAXDESC]; + const char *file; + int line; } malloc_entry; malloc_entry malloc_pointers[MAXMAL]; @@ -68,23 +70,25 @@ set_entry(int i, char *buf, size_t size, char *file, int line) { buf += UNDRRNVAL; malloc_pointers[i].ptr = buf; malloc_pointers[i].size = size; - sprintf(malloc_pointers[i].comm,"%s (%d)", file, line); + malloc_pointers[i].file = file; + malloc_pointers[i].line = line; return buf; } void malloc_state(void) { - int i, total = 0; + int i; + size_t total = 0; i_clear_error(); mm_log((0,"malloc_state()\n")); bndcheck_all(); for(i=0; i %d bytes allocated at %p for %s (%d)\n", i, size, buf, file, line)); + mm_log((1,"mymalloc_file_line: slot <%d> %ld bytes allocated at %p for %s (%d)\n", i, (long)size, buf, file, line)); return buf; } void * -(mymalloc)(int size) { +(mymalloc)(size_t size) { return mymalloc_file_line(size, "unknown", 0); } @@ -142,12 +146,13 @@ myrealloc_file_line(void *ptr, size_t newsize, char* file, int line) { } if ( (buf = realloc(((char *)ptr)-UNDRRNVAL, UNDRRNVAL+OVERRNVAL+newsize)) == NULL ) { - mm_log((1,"Unable to reallocate %i bytes at %p for %s (%i)\n", newsize, ptr, file, line)); + mm_log((1,"Unable to reallocate %ld bytes at %p for %s (%i)\n", (long) + newsize, ptr, file, line)); exit(3); } buf = set_entry(i, buf, newsize, file, line); - mm_log((1,"realloc_file_line: slot <%d> %d bytes allocated at %p for %s (%d)\n", i, newsize, buf, file, line)); + mm_log((1,"realloc_file_line: slot <%d> %ld bytes allocated at %p for %s (%d)\n", i, (long)newsize, buf, file, line)); return buf; } @@ -167,13 +172,15 @@ bndcheck(int idx) { return; } - for(i=0;i %p\n", size, buf)); + mm_log((1, "mymalloc(size %ld) -> %p\n", (long)size, buf)); return buf; } @@ -263,7 +263,7 @@ void * myrealloc(void *block, size_t size) { void *result; - mm_log((1, "myrealloc(block %p, size %u)\n", block, size)); + mm_log((1, "myrealloc(block %p, size %ld)\n", block, (long)size)); if ((result = realloc(block, size)) == NULL) { mm_log((1, "myrealloc: out of memory\n")); fprintf(stderr, "Out of memory.\n"); @@ -320,13 +320,13 @@ i_mempool_destroy(i_mempool *mp) { #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 (ab) return a; else return b; } @@ -345,18 +345,22 @@ struct utf8_size utf8_sizes[] = }; /* -=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 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 encoding used by later +versions of Perl. Since this is typically used to implement text +output by font drivers, the strings supplied shouldn't have such out +of range characters. -This doesn't check that the UTF8 charecter is using the shortest +This doesn't check that the C character is using the shortest possible representation. +Returns ~0UL on failure. + =cut */