… | |
… | |
49 | if (!value) { |
49 | if (!value) { |
50 | psiconv_warn(0,psiconv_list_length(buf),"Null section table section"); |
50 | psiconv_warn(0,psiconv_list_length(buf),"Null section table section"); |
51 | return -PSICONV_E_GENERATE; |
51 | return -PSICONV_E_GENERATE; |
52 | } |
52 | } |
53 | |
53 | |
54 | if (!(entry = malloc(sizeof(*entry)))) |
|
|
55 | return -PSICONV_E_NOMEM; |
|
|
56 | |
|
|
57 | if ((res = psiconv_write_u8(buf,2 * sizeof(psiconv_u32) * |
54 | if ((res = psiconv_write_u8(buf,2 * psiconv_list_length(value)))) |
58 | psiconv_list_length(value)))) |
55 | return res; |
59 | goto ERROR; |
|
|
60 | for (i = 0; i < psiconv_list_length(value); i++) { |
56 | for (i = 0; i < psiconv_list_length(value); i++) { |
61 | if (!(entry = psiconv_list_get(value,i))) { |
57 | if (!(entry = psiconv_list_get(value,i))) { |
62 | psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); |
58 | psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); |
63 | res = -PSICONV_E_NOMEM; |
59 | return -PSICONV_E_NOMEM; |
64 | goto ERROR; |
|
|
65 | } |
60 | } |
66 | if ((res = psiconv_write_u32(buf,entry->id))) |
61 | if ((res = psiconv_write_u32(buf,entry->id))) |
67 | goto ERROR; |
62 | return res; |
68 | if ((res = psiconv_write_u32(buf,entry->offset))) |
63 | if ((res = psiconv_write_u32(buf,entry->offset))) |
69 | goto ERROR; |
64 | return res; |
70 | } |
65 | } |
71 | res = -PSICONV_E_OK; |
66 | return -PSICONV_E_OK; |
72 | ERROR: |
|
|
73 | free(entry); |
|
|
74 | return res; |
|
|
75 | } |
67 | } |
76 | |
68 | |
77 | int psiconv_write_application_id_section(psiconv_buffer buf,psiconv_u32 id, |
69 | int psiconv_write_application_id_section(psiconv_buffer buf,psiconv_u32 id, |
78 | const psiconv_string_t text) |
70 | const psiconv_string_t text) |
79 | { |
71 | { |
… | |
… | |
113 | goto ERROR; |
105 | goto ERROR; |
114 | res = psiconv_list_concat(buf,extra_buf); |
106 | res = psiconv_list_concat(buf,extra_buf); |
115 | |
107 | |
116 | ERROR: |
108 | ERROR: |
117 | psiconv_free_buffer(extra_buf); |
109 | psiconv_free_buffer(extra_buf); |
|
|
110 | return res; |
118 | } |
111 | } |