]> Chaos Git - console/RCOMage.git/commitdiff
Use size_t type for arguments passed to iconv()
authorAntonio Ospite <ospite@studenti.unina.it>
Mon, 10 Jan 2011 15:58:10 +0000 (16:58 +0100)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Mon, 10 Jan 2011 20:40:05 +0000 (15:40 -0500)
On system where sizeof(size_t) != sizeof(uint32_t) iconv() was failing
and even segfaulting. Use the correct type and remove the now unneded
casts from the iconv() invocations.

This makes RCOmage finally work in linux on 64 bit systems as well.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
src/rcodump.c
src/xmlread.c

index 31eb0211f023d465815ab6e6ed8219f3cc17f08a..bfb620f5f8d963f1001d8456ce96fe4110fc1a8d 100644 (file)
@@ -445,7 +445,7 @@ dump_text_resources (char *labels, rRCOEntry * parent, uint8_t writeHeader,
     for (i = 0; i < textEntry->numIndexes; i++) {
       RCOTextIndex *idx = &(textEntry->indexes[i]);
       uint32_t len = strlen (get_label_from_offset (labels, idx->labelOffset));
-      uint32_t dataLen = 0;
+      size_t dataLen = 0;
 
       if (len > MAX_LABEL_LEN)
        len = MAX_LABEL_LEN;
@@ -510,7 +510,7 @@ dump_text_resources (char *labels, rRCOEntry * parent, uint8_t writeHeader,
 
        char buf[4096];
        char *bufOut = buf;
-       uint32_t outBufLen = 4096;
+       size_t outBufLen = 4096;
 
        /* { // feed in the BOM (is it really necessary though?) uint32_t
         * number; char* unicodePtr; if(textEntry->format ==
@@ -528,8 +528,8 @@ dump_text_resources (char *labels, rRCOEntry * parent, uint8_t writeHeader,
        uint32_t nullsStripped = 0;
 
        while (dataLen) {
-         iconv (ic, (&bufIn), (size_t *) (&dataLen), &bufOut,
-             (size_t *) (&outBufLen));
+         iconv (ic, (&bufIn), &dataLen, &bufOut,
+             &outBufLen);
          if (buf == bufOut) {
            warning ("iconv failed when converting resource '%s'.",
                get_label_from_offset (labels, idx->labelOffset));
index 9d72307485ec2e3a84daf64d8540f265b3bb75ce..180f92491291c0368f44889c33e1c332ae9fcbf7 100644 (file)
@@ -1750,8 +1750,8 @@ parse_text_xml (char *fn, rRCOFile * rco, rRCOEntry * entry)
              }
            }
            if (te->indexes[i].length > 2) {
-             uint32_t contentLen = xmlStrlen (n), outBufLen =
-                 te->indexes[i].length;
+             size_t contentLen = xmlStrlen (n);
+             size_t outBufLen = te->indexes[i].length;
 
              textBuffer =
                  realloc (textBuffer,
@@ -1768,14 +1768,14 @@ parse_text_xml (char *fn, rRCOFile * rco, rRCOEntry * entry)
              if ((*(uint32_t *) n & 0xFFFFFF) == UTF8_BOM) {
                char bom[4];
                char *bomPtr = bom;
-               uint32_t bomLen =
+               size_t bomLen =
                    (fmt == RCO_TEXT_FMT_UTF32 ? 4 : (fmt ==
                        RCO_TEXT_FMT_UTF8 ? 3 : 2));
-               iconv (ic, (char **) (&n), (size_t *) (&contentLen),
-                   (char **) &bomPtr, (size_t *) (&bomLen));
+               iconv (ic, (char **) (&n), &contentLen,
+                   (char **) &bomPtr, &bomLen);
              }
-             iconv (ic, (char **) (&n), (size_t *) (&contentLen), &tbPtr,
-                 (size_t *) (&outBufLen));
+             iconv (ic, (char **) (&n), &contentLen, &tbPtr,
+                 &outBufLen);
              if (outBufLen && outBufLen == charWidth) {        // *should*
                // always be
                // true