[trunk] Remove old function tgt_create
Fix some warnings about size_t
This commit is contained in:
parent
3ad58ee1f5
commit
394db7b738
@ -51,6 +51,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -78,7 +79,7 @@ int main(int argc, char *argv[])
|
||||
long fsize, boxsize;
|
||||
|
||||
if( argc<3){
|
||||
fprintf( stderr, "USAGE: ./addXMLinJP2 modifing.jp2 adding.xml\n");
|
||||
fprintf( stderr, "USAGE: %s modifing.jp2 adding.xml\n", argv[0] );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -87,6 +88,7 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
|
||||
xmldata = read_xmlfile( argv[2], &fsize);
|
||||
if( fsize < 0 ) return -1;
|
||||
boxsize = fsize + 8;
|
||||
|
||||
fputc( (boxsize>>24)&0xff, fp);
|
||||
@ -94,7 +96,7 @@ int main(int argc, char *argv[])
|
||||
fputc( (boxsize>>8)&0xff, fp);
|
||||
fputc( boxsize&0xff, fp);
|
||||
fwrite( type, 4, 1, fp);
|
||||
fwrite( xmldata, fsize, 1, fp);
|
||||
fwrite( xmldata, (size_t)fsize, 1, fp);
|
||||
|
||||
free( xmldata);
|
||||
fclose(fp);
|
||||
@ -159,6 +161,7 @@ char * read_xmlfile( const char filename[], long *fsize)
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
assert( *fsize >= 0 );
|
||||
|
||||
if( fseek( fp, 0, SEEK_SET) == -1){
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
@ -166,9 +169,9 @@ char * read_xmlfile( const char filename[], long *fsize)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( *fsize);
|
||||
data = (char *)malloc( (size_t)*fsize);
|
||||
|
||||
if( fread( data, *fsize, 1, fp) != 1){
|
||||
if( fread( data, (size_t)*fsize, 1, fp) != 1){
|
||||
fprintf( stderr, "XML file %s broken (read error)\n", filename);
|
||||
free( data);
|
||||
fclose(fp);
|
||||
|
@ -97,7 +97,7 @@ opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ..
|
||||
|
||||
if ((fmt != NULL) && (event_mgr != NULL)) {
|
||||
va_list arg;
|
||||
int str_length/*, i, j*/; /* UniPG */
|
||||
size_t str_length/*, i, j*/; /* UniPG */
|
||||
char message[MSG_SIZE];
|
||||
memset(message, 0, MSG_SIZE);
|
||||
/* initialize the optional parameter list */
|
||||
@ -148,7 +148,7 @@ opj_bool opj_event_msg_v2(opj_event_mgr_t* p_event_mgr, int event_type, const ch
|
||||
|
||||
if ((fmt != 00) && (p_event_mgr != 00)) {
|
||||
va_list arg;
|
||||
int str_length/*, i, j*/; /* UniPG */
|
||||
size_t str_length/*, i, j*/; /* UniPG */
|
||||
char message[MSG_SIZE];
|
||||
memset(message, 0, MSG_SIZE);
|
||||
/* initialize the optional parameter list */
|
||||
|
@ -919,7 +919,7 @@ opj_bool FUNCTION ( opj_tcd_v2_t *p_tcd, \
|
||||
} \
|
||||
\
|
||||
if (! l_current_precinct->incltree) { \
|
||||
l_current_precinct->incltree = tgt_create_v2(l_current_precinct->cw, \
|
||||
l_current_precinct->incltree = tgt_create(l_current_precinct->cw, \
|
||||
l_current_precinct->ch); \
|
||||
} \
|
||||
else{ \
|
||||
@ -934,7 +934,7 @@ opj_bool FUNCTION ( opj_tcd_v2_t *p_tcd, \
|
||||
} \
|
||||
\
|
||||
if (! l_current_precinct->imsbtree) { \
|
||||
l_current_precinct->imsbtree = tgt_create_v2( \
|
||||
l_current_precinct->imsbtree = tgt_create( \
|
||||
l_current_precinct->cw, \
|
||||
l_current_precinct->ch); \
|
||||
} \
|
||||
|
@ -37,78 +37,7 @@
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv) {
|
||||
int nplh[32];
|
||||
int nplv[32];
|
||||
opj_tgt_node_t *node = NULL;
|
||||
opj_tgt_node_t *parentnode = NULL;
|
||||
opj_tgt_node_t *parentnode0 = NULL;
|
||||
opj_tgt_tree_t *tree = NULL;
|
||||
int i, j, k;
|
||||
int numlvls;
|
||||
int n;
|
||||
|
||||
tree = (opj_tgt_tree_t *) opj_malloc(sizeof(opj_tgt_tree_t));
|
||||
if(!tree) return NULL;
|
||||
tree->numleafsh = numleafsh;
|
||||
tree->numleafsv = numleafsv;
|
||||
|
||||
numlvls = 0;
|
||||
nplh[0] = numleafsh;
|
||||
nplv[0] = numleafsv;
|
||||
tree->numnodes = 0;
|
||||
do {
|
||||
n = nplh[numlvls] * nplv[numlvls];
|
||||
nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
|
||||
nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
|
||||
tree->numnodes += n;
|
||||
++numlvls;
|
||||
} while (n > 1);
|
||||
|
||||
/* ADD */
|
||||
if (tree->numnodes == 0) {
|
||||
opj_free(tree);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes, sizeof(opj_tgt_node_t));
|
||||
if(!tree->nodes) {
|
||||
opj_free(tree);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node = tree->nodes;
|
||||
parentnode = &tree->nodes[tree->numleafsh * tree->numleafsv];
|
||||
parentnode0 = parentnode;
|
||||
|
||||
for (i = 0; i < numlvls - 1; ++i) {
|
||||
for (j = 0; j < nplv[i]; ++j) {
|
||||
k = nplh[i];
|
||||
while (--k >= 0) {
|
||||
node->parent = parentnode;
|
||||
++node;
|
||||
if (--k >= 0) {
|
||||
node->parent = parentnode;
|
||||
++node;
|
||||
}
|
||||
++parentnode;
|
||||
}
|
||||
if ((j & 1) || j == nplv[i] - 1) {
|
||||
parentnode0 = parentnode;
|
||||
} else {
|
||||
parentnode = parentnode0;
|
||||
parentnode0 += nplh[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
node->parent = 0;
|
||||
|
||||
tgt_reset(tree);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
opj_tgt_tree_t *tgt_create_v2(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
||||
opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
||||
OPJ_INT32 nplh[32];
|
||||
OPJ_INT32 nplv[32];
|
||||
opj_tgt_node_t *node = 00;
|
||||
|
@ -75,8 +75,7 @@ Create a tag-tree
|
||||
@param numleafsv Height of the array of leafs of the tree
|
||||
@return Returns a new tag-tree if successful, returns NULL otherwise
|
||||
*/
|
||||
opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv);
|
||||
opj_tgt_tree_t *tgt_create_v2(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv);
|
||||
opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv);
|
||||
|
||||
/**
|
||||
* Reinitialises a tag-tree from an exixting one.
|
||||
|
Loading…
x
Reference in New Issue
Block a user